Skip to content

fix: Handle leading whitespace in elided frames marker#138

Open
homme wants to merge 1 commit intouber-go:masterfrom
homme:fix-elided-frames-whitespace
Open

fix: Handle leading whitespace in elided frames marker#138
homme wants to merge 1 commit intouber-go:masterfrom
homme:fix-elided-frames-whitespace

Conversation

@homme
Copy link
Copy Markdown

@homme homme commented Nov 5, 2025

Fixes panic when parsing stack traces with indented elided frames marker.

Problem

Go's runtime can elide frames in very deep stack traces (e.g., AWS SDK v2 middleware with 33+ frames). The elision marker ...N frames elided... appears with leading whitespace (tabs/spaces), but the parser only checked for lines starting with ....

When the indented marker wasn't caught, it was passed to parseFuncName(), causing a panic: no function found: "...33 frames elided..."

Solution

Trim whitespace before checking for the elision marker pattern. This allows both indented and non-indented markers to be handled gracefully.

Example (Go 1.25.1)

        github.com/aws/aws-sdk-go-v2/service/sqs.(*disableHTTPSMiddleware).HandleFinalize(...)
        	/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/sqs@v1.42.11/api_client.go:864 +0x143
        ...33 frames elided...
        github.com/aws/aws-sdk-go-v2/aws/middleware.ClientRequestID.HandleBuild(...)
        	/go/pkg/mod/github.com/aws/aws-sdk-go-v2@v1.39.4/aws/middleware/middleware.go:42 +0x1e5

Note the leading whitespace before ...33 frames elided....

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Nov 5, 2025

CLA assistant check
All committers have signed the CLA.

The stack trace elision marker "...N frames elided..." can appear with
leading whitespace (tabs/spaces) in deep call stacks, particularly from
AWS SDK v2 middleware chains (33+ frames).

The parser was only checking for lines starting with "...", causing it
to pass indented elision markers to parseFuncName(), which panicked with
"no function found".

This fix trims whitespace before checking for the elision marker pattern,
allowing both indented and non-indented markers to be handled gracefully.

Example stack trace triggering the issue (Go 1.25.1):

        github.com/aws/aws-sdk-go-v2/service/sqs.(*disableHTTPSMiddleware).HandleFinalize(...)
        	/go/pkg/mod/github.com/aws/aws-sdk-go-v2/service/sqs@v1.42.11/api_client.go:864 +0x143
        ...33 frames elided...
        github.com/aws/aws-sdk-go-v2/aws/middleware.ClientRequestID.HandleBuild(...)
        	/go/pkg/mod/github.com/aws/aws-sdk-go-v2@v1.39.4/aws/middleware/middleware.go:42 +0x1e5
@homme homme force-pushed the fix-elided-frames-whitespace branch from 9700612 to 94b42c7 Compare November 5, 2025 17:49
@homme homme marked this pull request as ready for review November 5, 2025 17:50
Copy link
Copy Markdown
Collaborator

@abhinav abhinav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @homme.
This looks good, but would you mind adding a test case for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants