plasma-umass / Mesh

A memory allocator that automatically reduces the memory footprint of C/C++ applications.
Apache License 2.0
1.75k stars 73 forks source link

bug in the gcc lib #84

Open kyoguan opened 3 years ago

kyoguan commented 3 years ago

We found the gcc lib has a bug, call the system call futex without the FUTEX_PRIVATE_FLAG flag. This would block the thread after mesh, because the phys address changed. clang' lib without this bug.

eg. std::future would trigger this bug.

bobby-stripe commented 3 years ago

yikes! do you have links to the bug or a small reproducer? is it in libgcc or glibc? its surprising to me that freeing the meshed page wouldn't clear/purge the waiting futex, otherwise it seems like a process could get notified about a futex in a different process (if/when the memory is reused)

kyoguan commented 3 years ago

https://github.com/gcc-mirror/gcc/blob/df3e7e7eba31450357b3773f5fb028b5ec2d3669/libstdc%2B%2B-v3/src/c%2B%2B11/futex.cc

here: const unsigned futex_wait_op = 0; const unsigned futex_wake_op = 1;

they should be const unsigned futex_wait_op = 0 | 128; const unsigned futex_wake_op = 1 | 128;