-
Notifications
You must be signed in to change notification settings - Fork 538
Problem: zsys_init() + fork() causes undefined behaviour #1660
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
Conversation
Solution: zsys_shutdown() calls (new function) zsys_reset() as part of its cleanup, which resets all global state to their initial values. Which allows subsequent calls to zsys_init() to work as expected.
Thanks. I understand wanting to reset the global state, but there are 2 issues:
|
@bluca Thanks for explaining. It sounds like you didn't mean to merge this, but you did. Slip of the mouse? |
It was intentional - as you have read in the C4, we always merge PRs, apart from a few corner cases where things are really, really, really broken. This is not one of them. |
@bluca In that case, there's no reason not to call |
Release engineering of a public library is a delicate problem - even if there's no explicit promise, de-facto the current behaviour of these public APIs is that a shutdown follow by a re-init does not discard the previous settings of those various global context variables. This means this change can't go live (without the DRAFT flag) until we are ready to do an API-breaking release, which is very rare and should be at most once every couple of years. As a famous developer once said, if people are using it, it's not a bug, it's a feature. |
@bluca, I've read that carefully (thanks for explaining carefully). I have every respect for back-compat, and in other projects have acted the curmudgeon against other developers on that point. But I think this vigilance is simply misplaced here. To reiterate, the behavior this changes has never been exposed in an official release and is not documented (either way) anywhere. So changing it cannot qualify as a breaking change by any reasonable standard. Even the mere question of what the behavior is was a moot point until two weeks ago when #1649 was merged, because anyone who tried to exercise it was stopped by an assert before they got to. I know this because I pulled czmq 3 weeks ago, after 4.0.2, and was stopped in this way the moment I tried to invoke a czmq function in a new process after Seeing as it's standard C4 practice to merge a PR and then immediately change its behavior, it's clear that "it's in git between versions" isn't a de-facto contract to users. So how can changing another behavior that has only been public "in git between versions" be considered an API breaking change? Please reconsider whether you're actually protecting users (who ship stable products against an unreleased git version of czmq) or throwing a way an opportunity to correct an oversight, without hurtin anyone, that is about to become written in stone for a year or two (and then cause porting issues). If you still refuse to reconsider, I'll drop the issue.... ... And consider you wrong wrong wrong till my dying day 😉 |
Yes that's true, I hadn't considered that it was broken before, only that it was available |
👍 |
closes #1659.
First PR here. I've read and agree to C4.1.
This change requires (some) version change, because code that depends on this fix must have a way to check for it. Not sure how new minor/patch versions are handled in the project.
Follow up to #1649 (as it turns out), extending it to reset all global state, not just dangling pointers.