Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug in stacktrace.go Line 106: Incorrect Handling of Stack Trace Filtering #39

Open
britakin opened this issue Dec 2, 2024 · 0 comments

Comments

@britakin
Copy link

britakin commented Dec 2, 2024

In stacktrace.go, the logic relies on packageName := buildInfo.Path, assuming that buildInfo.Path represents the directory name of the oops package. However, buildInfo.Path contains the module path, not the package directory name. This discrepancy causes the following issues:

Stack trace filtering logic incorrectly includes or excludes frames.
Inconsistent behavior when the library is used in different environments (e.g., local applications, larger projects).

Problem:
The relevant code in stacktrace.go:

packageName := buildInfo.Path
isOopsPkg := strings.Contains(file, packageName)

Here, buildInfo.Path does not correspond to the directory or package name of oops, leading to incorrect filtering of stack trace entries.

Impact:

  • The stack trace may include irrelevant frames or exclude crucial ones.
  • Debugging becomes unreliable when using the library.

Steps to Reproduce:

  1. Create a Go project that uses the oops library.
  2. Trigger an error in the local application context.
  3. Inspect the generated stack trace.

Expected Behavior:
The stack trace should correctly include all relevant frames without excluding valid entries or including irrelevant ones.

Actual Behavior:
Stack trace filtering behaves unpredictably due to overly broad strings.Contains matching.
Valid stack trace entries are excluded or irrelevant entries are included.

Suggested Fix:
Refine the logic in stacktrace.go to ensure accurate identification of package-related stack trace frames. A possible solution:
Use exact string matching or a more robust path parsing method instead of strings.Contains.
Consider leveraging path/filepath to handle package and file path comparisons in a platform-independent way.
This ensures that the match is explicit and avoids unintended partial matches.

Environment:

  • Go version: go version go1.23.3 darwin/arm64
  • oops library version: v1.14.1
  • Operating system: macOS

Additional Notes:
This issue might affect other similar filtering logic within the library, so a thorough review is recommended. I can provide more detailed examples or a reproducible demo if needed.

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

No branches or pull requests

1 participant