Skip to content

Fix stack alignment computation (#12267)#12434

Merged
gasche merged 1 commit intotrunkfrom
unknown repository
Aug 2, 2023
Merged

Fix stack alignment computation (#12267)#12434
gasche merged 1 commit intotrunkfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Jul 27, 2023

Following issue #12267, this PR:

  • relaxes the assertion to only confirm that the allocated stack size is at least equal to the requested size, since alignment may cause more than one extra word to have been allocated.
  • fixes the alignment computation of the top of the stack, using the (size + align - 1) & ~(align - 1) idiom as found is round_up() in runtime/platform.c (which can't be used directly as it local to that file).

The previous computation did not round up correctly. If the top of stack would have ended up being 0x...4, it would end up truncated to 0x...0.

@gasche
Copy link
Member

gasche commented Aug 1, 2023

@dustanddreams could you rebase (there is a Changes conflict) and fixup the history?

The previous computation would not always round up and actually truncate
the allocation on 32-bit platforms, if the requested size in words is
congruent to 1 modulo 4.
@ghost
Copy link
Author

ghost commented Aug 2, 2023

@dustanddreams could you rebase (there is a Changes conflict) and fixup the history?

Rebasquashed.

@gasche gasche merged commit 14ed172 into ocaml:trunk Aug 2, 2023
@gasche
Copy link
Member

gasche commented Aug 2, 2023

Thanks! Merged.

@dra27
Copy link
Member

dra27 commented Aug 21, 2023

Given that there's another fix needed for 5.1 (so presumably another rc?), can I add this to the 5.1 milestone, @Octachron? (and then cherry-pick!)

@ghost ghost deleted the stack_alignment_12267 branch October 30, 2023 08:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants