Need to place static proc objects into 8-byte alignments#6338
Merged
matz merged 1 commit intomruby:masterfrom Sep 11, 2024
Merged
Need to place static proc objects into 8-byte alignments#6338matz merged 1 commit intomruby:masterfrom
matz merged 1 commit intomruby:masterfrom
Conversation
Static proc objects defined as methods may be placed in 4-byte alignments in 32-bit environments. This may be misinterpreted as an immediate value depending on the address. Since C11 and C++11 have additional language features for byte alignment, corresponding compilers use them to define the `mrb_alignas()` macro. For earlier compilers, they use their own extensions to define the `mrb_alignas()` macro. GCC supports `__attribute__((aligned(alignment)))` since at least version 2.95.3 (1999). https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#IDX305 According to GPT-4, support was added in version 2.7 (1995). It is not known which version of Visual C++ added support for `__declspec(align(n))`. According to GPT-4, at least Visual C++ 6.0 (1998) seems to support it. Also, the documentation of past Intel C/C++ compilers that support `__declspec(align(n))` makes reference to support with Visual C++ 4.2 (1996). https://www.intel.com/content/dam/www/public/ijkk/jp/ja/documents/developer/ccomp40j.pdf
Contributor
Author
|
I had the same problem when I tested 32-bit binaries built with mingw32 on FreeBSD with wine. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Static proc objects defined as methods may be placed in 4-byte alignments in 32-bit environments.
This may be misinterpreted as an immediate value depending on the address.
Since C11 and C++11 have additional language features for byte alignment, corresponding compilers use them to define the
mrb_alignas()macro.For earlier compilers, they use their own extensions to define the
mrb_alignas()macro.GCC supports
__attribute__((aligned(alignment)))since at least version 2.95.3 (1999).https://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html#IDX305
According to GPT-4, support was added in version 2.7 (1995).
It is not known which version of Visual C++ added support for
__declspec(align(n)).According to GPT-4, at least Visual C++ 6.0 (1998) seems to support it.
Also, the documentation of past Intel C/C++ compilers that support
__declspec(align(n))makes reference to support with Visual C++ 4.2 (1996).https://www.intel.com/content/dam/www/public/ijkk/jp/ja/documents/developer/ccomp40j.pdf
I noticed this problem when building mruby for i386 with clang (version 18.1.5) on FreeBSD 14.1 amd64.
Running
bin/mrbtestcrashes due toSIGSEGV.I use gdb because lldb did not track 32-bit binaries well.
build configuration file
result with gdb