-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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 memory leak in syslog extension #12501
Conversation
@@ -96,23 +96,9 @@ PHP_MINIT_FUNCTION(syslog) | |||
} | |||
/* }}} */ | |||
|
|||
PHP_RINIT_FUNCTION(syslog) |
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.
Removed the rinit function because we already do BG(syslog_device)=NULL
in the minit function, plus this is what causes the leak.
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 think the fix is wrong. With the patch openlog()
called in first request may have effect on syslog()
called in second request.
@dstogov But I explicitly call closelog in the rshutsown (not mshutdown) function and clear the prefix buffer, on the contrary shouldn't that completely reset the syslog state after each request finishes? |
Ah, I messed RSHUTDOWN and MSHUTDOWN... |
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.
Looks good
I think it makes sense but leave it open for a little bit. I want to test few things if set from FPM config or through fcgi. Should be fine but just want to verify. |
@bukka any results? |
I plan to test it at the end of this week. |
I just had a proper look on this and it is actually fine as the value was reset already - just leaking. Think this makes more sense so merged. |
This change broke something in ZTS during shutdown. I'm seeing a lot of extension faults like this:
Looks like this is not initialized correctly due to removal of RINIT: Line 47 in cc2bf11
|
Hmm, we already do |
Ah, it should be initialized in GINIT, not in MINIT... |
Hopefully this will do: #12663 |
The leak can be easily reproduced with ASAN:
a.php:
Result: