Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant