-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fixed memory leak from sigaltstack. #11167
Conversation
As a newcomer to this part of the runtime, I was surprised by this PR because "freeing the signal stack" was already discussed in #10726 and I understood it to be a solved issue. Here is what I understand:
(Why is this not an issue for other cleanup things that are done in Ideally each |
One aspect I wonder about is: shouldn't we call (cc @dra27 @kayceesrk @ctk21 @Engil) |
@gasche Vast majority of other allocation is done with As for if it is the best solution, I have no idea. |
Just as a note, I think everything in #10726 was (intentionally) lost as part of the multicore PR merge, so it's not completely surprising that this might have reappeared. The sigaltstack freeing in 4.x is tied in with 4.x's signal handling, which is completely overhauled in 5.0 |
If I'm correct that trunk of 5.0 is https://github.com/ocaml-multicore/ocaml-multicore then it isn't fixed as there is the complementary problem (freeing stack without reseting). I've created an issue for that ocaml-multicore/ocaml-multicore#838 |
The ocaml-multicore repository is mostly for historical interest now (earlier versions of multicore, and so forth) - it's just branch |
I've created a new proposition in https://github.com/azewierzejew/ocaml/tree/signal-stack-fix-alternative |
Your "alternative" PR is sensibly more invasive in terms of change, and I don't feel competent enough to review it by myself. It combines three things:
I would be in favor of un-drafting the present PR and merging it to fix the leak, and then discussing restructurations as a second step. |
Agree with @gasche , we should un-draft this PR, merge it and then follow up with a restructuring. |
This mirrors the structure of the initialization code, where
We're in the same boat, it's not a trivial change, but I have a good feeling about it: I think it's more likely to be right (and remain right as the code evolves) as the current approach -- we should ensure that |
I undrafted the PR. As for using Similar things happens to |
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'm approving the current minimal fix, hoping that we can discuss restructuration of the cleanup code next.
Also calling |
@azewierzejew if you could do an update of Changes with reviewers, that should also give appveyor a kick and once it's all green I can merge. |
Thanks @azewierzejew ! |
Currently stack for handling signals on the first domain always leaks.
As far as I have read the code extra spawned domains have their stacks cleared on exit.
The following fix clears the stack on the original domain.
It wouldn't free data if
caml_shutdown
was called on different thread thancaml_startup_pooled
.It wouldn't break anything either way (as the function would do nothing).
But I don't know whether calling those functions from different threads is allowed.