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

Asan error spotted building JDK with gcc 13.2.0 #1747

Open
SoniaZaldana opened this issue Apr 17, 2024 · 0 comments
Open

Asan error spotted building JDK with gcc 13.2.0 #1747

SoniaZaldana opened this issue Apr 17, 2024 · 0 comments

Comments

@SoniaZaldana
Copy link

SoniaZaldana commented Apr 17, 2024

Hi all,

I've come across a bug with asan while building the JDK with gcc 13.2.0. Find the bug reported in the JDK as well here.

Please find the stack trace below:

/home/szaldana/jdk/src/hotspot/share/gc/z/zMarkStack.cpp: In constructor ‘ZMarkStripeSet::ZMarkStripeSet(uintptr_t)’:
/home/szaldana/jdk/src/hotspot/share/gc/z/zMarkStack.cpp:43:17: error: writing 80 bytes into a region of size 8 [-Werror=stringop-overflow=]
   43 | _stripes[i] = ZMarkStripe(base);
      | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /home/szaldana/jdk/src/hotspot/share/gc/z/zMarkStack.inline.hpp:27,
                 from /home/szaldana/jdk/src/hotspot/share/gc/z/zMarkStack.cpp:25:
/home/szaldana/jdk/src/hotspot/share/gc/z/zMarkStack.hpp:57:15: note: destination object ‘ZStackList<ZStack<ZMarkStackEntry, 254> >::_base’ of size 8
   57 | uintptr_t _base;
      | ^~~~~
/home/szaldana/jdk/src/hotspot/share/gc/z/zMarkStack.cpp:43:17: error: writing 80 bytes into a region of size 8 [-Werror=stringop-overflow=]
   43 | _stripes[i] = ZMarkStripe(base);
      | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/home/szaldana/jdk/src/hotspot/share/gc/z/zMarkStack.hpp:57:15: note: destination object ‘ZStackList<ZStack<ZMarkStackEntry, 254> >::_base’ of size 8
   57 | uintptr_t _base;
      | ^~~~~

The "region of size 8" seems like a bug in ASAN. It is presumably what ASAN thinks is the size of _stripes[i] in zMarkStack.cpp, but that's wrong.

ZMarkStripe is made up of two ZStackList entries. Note how each one of those is 16 bytes.

Additionally, note how ZStackList is 64 byte aligned to make each one have its own cache line. So the memory layout is something like this:

0 ---
  ZStackList 
16 ----
  padding
64 ----
  ZStackList
80 ---
  padding 
128 ---

Thus, sizeof(ZMarkStripe) should be 128.

On the other hand, the "writing 80 bytes" seems correct, as that is the size of ZMarkStripe excluding trailing padding. The assignment doesn't need to copy that trailing padding.

If you'd like to reproduce the bug, it suffices to build the jdk passing the --enable-asan flag to the bash configure arguments.

Looking forward to your comments!

Sonia

[Update] I've also directly filed with gcc if that is the more appropriate avenue.

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

No branches or pull requests

1 participant