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

Fix bh_assert on 64-bit platforms #2071

Merged

Conversation

loganek
Copy link
Collaborator

@loganek loganek commented Mar 27, 2023

In some cases (for me, every time I use memory sanitizer) the memory address of some of the variables has 4 least significant bytes set to zero. Because we cast the pointer to int, we look only at 4 (at least on my system, but I guess on many other systems too) least significant bytes; the assertion fails because 4 least significant bytes are 0.

I change bh_assert implementation so it casts to int64_t and it works well with 64-bit architectures.

@loganek loganek force-pushed the loganek/fix-memory-sanitizer branch from e031836 to 27a02b7 Compare March 27, 2023 20:57
@loganek loganek changed the title Fix bh_assert on x64 systems Fix bh_assert on 64-bit platforms Mar 27, 2023
In some cases (for me, every time I use memory sanitizer) the memory address
of some of the variables has 4 least significant bytes set to zero. Because
we cast the pointer to int, we look only at 4 (at least on my system, but I
guess on many other systems too) least significant bytes; the assertion fails
because 4 least significant bytes are 0.

I change bh_assert implementation so it casts to int64_t and it works well
with 64-bit architectures.
@loganek loganek force-pushed the loganek/fix-memory-sanitizer branch from 27a02b7 to fdf8a05 Compare March 27, 2023 20:58
@wenyongh wenyongh merged commit ff4be24 into bytecodealliance:main Mar 28, 2023
victoryang00 pushed a commit to victoryang00/wamr-aot-gc-checkpoint-restore that referenced this pull request May 27, 2024
In some cases, the memory address of some variables may have 4 least significant
bytes set to zero. Because we cast the pointer to int, we look only at 4 least
significant bytes; the assertion may fail because 4 least significant bytes are 0.

Change bh_assert implementation to cast the assert expr to int64_t and it works
well with 64-bit architectures.
@loganek loganek deleted the loganek/fix-memory-sanitizer branch June 10, 2024 12:48
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.

None yet

2 participants