-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Fix flex overflow #1650
Fix flex overflow #1650
Conversation
@fbs I encountered the following memleaks. Do you think your PRs fix them? Or is this different issue? Maybe my error handling is wrong.
|
I don't have any prs related to this open so it must be something else. Maybe the driver.root isn't deleted properly after the error? |
hmm.. deleting |
It seems #1651 accidentally close this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit but LGTM
Maybe yyterminate() prevents some kind of memory cleanup? |
Previously, ``` % cat a.h # define B A # define A B ``` then ``` % sudo ./src/bpftrace --include a.h -e 'BEGIN {A}' // infinite loops ``` to solve this problem, limit the numbuer of unputs in the lexer. The magic number 1000 is no particular meanings. I think it's just enough. Now the above example becomes ``` % sudo ./src/bpftrace --include a.h -e 'BEGIN {A}' stdin:1:7-1008: ERROR: Too deep recursive macros detected' BEGIN {A} ~~~ stdin:1:7-1008: ERROR: syntax error, unexpected end of file, expecting } BEGIN {A} ~~~ ```
For example, ``` %cat b.h #define B BBBBBBBBBBBBBBB ``` then, ``` % sudo ./src/bpftrace --include b.h -e 'BEGIN {B}' flex scanner push-back overflow ``` To cope with this, check flex's buffers length (yyleng) and if we try to unput more than the length, stop lexer. Now the above example becomes ``` % sudo ASAN_OPTIONS=detect_leaks=0 ./src/bpftrace --include b.h -e 'BEGIN {B}' stdin:1:7-9: ERROR: Too deep recursive or long macro is detected: B, BBBBBBBBBBBBBBB BEGIN {B} ~~ stdin:1:7-9: ERROR: syntax error, unexpected end of file, expecting } BEGIN {B} ~~ ```
6195388
to
07afec4
Compare
OK, I'll merge this for now and create an issue with the memleaks. |
Add workaround for flex scanner push-back overflow.
Closes #1618
Checklist
docs/reference_guide.md
CHANGELOG.md