Skip to content
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

use a volatile pointer to call slp_switch #183

Closed
akruis opened this issue Nov 12, 2018 · 1 comment
Closed

use a volatile pointer to call slp_switch #183

akruis opened this issue Nov 12, 2018 · 1 comment

Comments

@akruis
Copy link

akruis commented Nov 12, 2018

If the internal stack transfer function slp_switch() is implemented using gcc/clang inline assembly, the inline assembly depends on the register allocation rules defined in the ABI-specification of the respective platform. Now if compiler inlines the function, the register allocation rules no longer apply and the behaviour is undefined.

Experiments show that the only reliable way to prevent inlining is to call slp_switch() using a volatile pointer. Here is the patch.

This has the additional advantage that slp_switch() now can be declared static, which reduces namespace pollution.

@akruis akruis added this to the v3.7.x-slp milestone Nov 12, 2018
@akruis akruis self-assigned this Nov 12, 2018
akruis pushed a commit that referenced this issue Nov 19, 2018
Prevent inlining slp_switch() more reliably. C standard guarantees to read
the value of a volatile variable from memory on each access. Therefore
the compiler does not know the called function and can't inline.
@akruis
Copy link
Author

akruis commented Nov 20, 2018

Done

@akruis akruis closed this as completed Nov 20, 2018
akruis pushed a commit that referenced this issue Dec 25, 2018
Prevent inlining slp_switch() more reliably. C standard guarantees to read
the value of a volatile variable from memory on each access. Therefore
the compiler does not know the called function and can't inline.

(cherry picked from commit 78f6b66)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant