Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.4k
http_parser: do not dealloc during kOnExecute#2956
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
indutny commented Sep 18, 2015
Test is a bit complicated, because the crash happens only on the access to the uninitialized memory. |
indutny commented Sep 18, 2015
bnoordhuis commented Sep 18, 2015
What commit or commits introduced the regression? |
src/node_http_parser.cc Outdated
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.
Consider doing CHECK(p_->refcount_ > 0) first in this function.
indutny commented Sep 18, 2015
The regression happened at: 1bc4468 |
indutny commented Sep 18, 2015
@bnoordhuis all fixed. |
bnoordhuis commented Sep 18, 2015
Create 1,000 or 10,000 parser objects and close them from within .execute(). One of them is bound to trigger the crash.
Can you include that in the commit log? Maybe also reference the first line of its commit log, that saves the log spelunker an extra |
indutny commented Sep 18, 2015
@bnoordhuis included. Will work on the test, but it won't be reliable unless started under valgrind. |
indutny commented Sep 18, 2015
Thank you! |
src/node_http_parser.cc Outdated
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.
By the way, you can initialize it to 1 here.
trevnorris commented Sep 18, 2015
trevnorris commented Sep 18, 2015
Outside of including a test, don't see anything I would change. LGTM. |
indutny commented Sep 18, 2015
Force pushed, PTAL |
indutny commented Sep 18, 2015
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.
Wouldn't it be better to have a const here?
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.
I don't think that delete may be called on const pointer... Am I wrong?
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.
@indutny I just tried this
# include<cstdio>classTest{public:Test(constchar * str) : my_str(str){} ~Test(){fprintf(stderr, "Cleaning up"); delete my_str} private:constchar * my_str}; intmain(){Test test(newchar[50])}with
➜ Desktop g++ Test.cpp && ./a.out Cleaning up ➜ Desktop 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.
-Wall?
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.
@indutny Hmmm, I tried that now. No warnings.
➜ Desktop g++ -Wall Test.cpp && ./a.out Cleaning up ➜ Desktop 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.
Oh, I think you're right.
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.
Anyway, I'm changing the refcount of the parser, so it won't work.
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.
@indutny Ah, right. Sorry for the fuss.
`freeParser` deallocates `Parser` instances early if they do not fit into the free list. This does not play well with recent socket consumption change, because it will try to deallocate the parser while executing on its stack. Regression was introduced in: 1bc4468 Fix: nodejs#2928
indutny commented Sep 19, 2015
CI is green. Shall I land it? |
trevnorris commented Sep 19, 2015
LGTM |
indutny commented Sep 19, 2015
Landed in 229a03f, thank you! |
`freeParser` deallocates `Parser` instances early if they do not fit into the free list. This does not play well with recent socket consumption change, because it will try to deallocate the parser while executing on its stack. Regression was introduced in: 1bc4468 Fix: #2928 PR-URL: #2956 Reviewed-by: Trevor Norris <[email protected]>
stephank commented Sep 19, 2015
Awesome! Thanks guys! 💪 |
`freeParser` deallocates `Parser` instances early if they do not fit into the free list. This does not play well with recent socket consumption change, because it will try to deallocate the parser while executing on its stack. Regression was introduced in: 1bc4468 Fix: #2928 PR-URL: #2956 Reviewed-by: Trevor Norris <[email protected]>
MylesBorins commented Nov 16, 2015
landed in lts-v4.x-staging as bc9f629 |
freeParserdeallocatesParserinstances early if they do not fitinto the free list. This does not play well with recent socket
consumption change, because it will try to deallocate the parser while
executing on its stack.
Fix: #2928
cc @nodejs/collaborators @trevnorris@bnoordhuis