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

Unportable usage of bit fields #143

Closed
akruis opened this issue Nov 5, 2017 · 1 comment
Closed

Unportable usage of bit fields #143

akruis opened this issue Nov 5, 2017 · 1 comment

Comments

@akruis
Copy link

akruis commented Nov 5, 2017

The "flags" member of Stackless tasklets and channels is a bit-field structure (PyTaskletFlagStruc and PyChannelFlagStruc). The methods tasklet_new, channel_new, tasklet_reduce, channel_reduce, tasklet_setstate and channel_setstate access the "flags" structure in an undefined (strict aliasing violation) or implementation defined way. Using bit-fields in a portable way is difficult and has been discussed widely. In short: placement of bit-field members in the storage unit is implementation defined. For details consult the language definition.

My fix will default to a slow but portable solution with the option to use the native memory layout, if we know that the compiler uses the conventional placement (first member starts at the least significant bit of the storage unit, other members follows immediately). Currently I know that x86 and amd64 are safe.

@akruis akruis added this to the v3.6.x-slp milestone Nov 5, 2017
akruis pushed a commit that referenced this issue Nov 5, 2017
- avoid type punning / strict aliasing violations
- don't rely on implementation defined placement of bit-fields in the
storage unit.
akruis pushed a commit that referenced this issue Nov 5, 2017
- avoid type punning / strict aliasing violations
- don't rely on implementation defined placement of bit-fields in the
storage unit.
(cherry picked from commit b9c243a)
akruis pushed a commit that referenced this issue Nov 5, 2017
- avoid type punning / strict aliasing violations
- don't rely on implementation defined placement of bit-fields in the
storage unit.

(cherry picked from commit 5512131)
akruis pushed a commit that referenced this issue Nov 5, 2017
- avoid type punning / strict aliasing violations
- don't rely on implementation defined placement of bit-fields in the
storage unit.
(cherry picked from commit b9c243a)
@akruis akruis self-assigned this Nov 5, 2017
@akruis
Copy link
Author

akruis commented Nov 5, 2017

Fixed. I had to backport the macro Py_BUILD_ASSERT_EXPR(cond) from 3.x to 2.7.

@akruis akruis closed this as completed Nov 5, 2017
akruis pushed a commit that referenced this issue Dec 21, 2017
Stackless contributes two tests to builtins: TaskletExit and
TaskletExit.__init__. Therefore we have to adjust the limit.

Add missing changelog entries (#143, #144).
akruis pushed a commit that referenced this issue Dec 21, 2017
Stackless contributes two tests to builtins: TaskletExit and
TaskletExit.__init__. Therefore we have to adjust the limit.

Add missing changelog entries (#143, #144).

(cherry picked from commit 7327e4b)
akruis pushed a commit that referenced this issue Dec 21, 2017
Stackless contributes two tests to builtins: TaskletExit and
TaskletExit.__init__. Therefore we have to adjust the limit.

Add missing changelog entries (#143, #144).

(cherry picked from commit 7327e4b)
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