py/nlr: In MP_NLR_JUMP_HEAD make top and top_ptr volatile. #5008
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The unix coverage port currently crashes with the toolchain and set up that I'm using (gcc 9.1.0 on Arch Linux x86-64). This is due to gcc doing further optimisations which leads to the following code being omitted (ie no corresponding machine code generated) in
MP_NLR_JUMP_HEAD
:This is because the nlr_jump function is marked as no-return, so gcc deduces that the above code has no effect (rightfully so, I guess).
I'm not very happy with the solution presented here, rather it's more for discussion how to resolve the problem properly (and as an workaround if necessary).
There could be other variables that need to be declared volatile (eg to do with PYSTACK), and other platforms (non x86-64) may have different behaviour and require other fixes.
This really points to the importance of #4131, removal of NLR completely.