Skip to content

[libc] fix scudo integration build #116979

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

Merged
merged 2 commits into from
Nov 20, 2024
Merged

Conversation

SchrodingerZhu
Copy link
Contributor

FYI, scudo is using our header while not using our implementation.

@llvmbot
Copy link
Member

llvmbot commented Nov 20, 2024

@llvm/pr-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

Changes

FYI, scudo is using our header while not using our implementation.


Full diff: https://github.com/llvm/llvm-project/pull/116979.diff

1 Files Affected:

  • (modified) libc/test/integration/scudo/CMakeLists.txt (+9)
diff --git a/libc/test/integration/scudo/CMakeLists.txt b/libc/test/integration/scudo/CMakeLists.txt
index a5f7e3b63d24c3..06d7ee6eca67d7 100644
--- a/libc/test/integration/scudo/CMakeLists.txt
+++ b/libc/test/integration/scudo/CMakeLists.txt
@@ -21,6 +21,15 @@ add_entrypoint_library(
     libc.src.errno.errno
     libc.src.unistd.__llvm_libc_syscall
     libc.src.sched.__sched_getcpucount
+    libc.src.unistd.sysconf
+    libc.src.sys.auxv.getauxval
+    libc.src.sys.prctl.prctl
+    libc.src.sys.mman.mmap
+    libc.src.sys.mman.munmap
+    libc.src.unistd.read
+    libc.src.unistd.write
+    libc.src.unistd.close
+    libc.src.fcntl.open
 )
 
 add_executable(

@SchrodingerZhu SchrodingerZhu merged commit 84d853a into llvm:main Nov 20, 2024
5 of 6 checks passed
@SchrodingerZhu SchrodingerZhu deleted the scudo branch November 20, 2024 14:53
@michaelrj-google
Copy link
Contributor

Thanks for fixing this! At some point I want to address the comment I left in this file and make this a proper integration test, so I'll file an issue for that.

@nickdesaulniers
Copy link
Member

Thanks for figuring this out! It had me stumped yesterday. Can you tell me a little more about how you ended up figuring this out?

@SchrodingerZhu
Copy link
Contributor Author

SchrodingerZhu commented Nov 20, 2024

@nickdesaulniers I am not sure why it does not reproduce on your side, but it just reproduces and the debugging story starts there.

So I just attached the debugger and found out that it errors out on a failure of mmap. Using strace, I can see that the failed mmap is to apply a MAP_FIXED on an address that is not page-aligned.

Then, it just comes to me that the allocator may get the wrong page size.

I re-run the test with debugger attached, and I tried sysconf(1) in the debugger (_SC_PAGESIZE=1 in our header), and it returned a value that is apparently not correct.

So, it must be the case that the implementation does not match the header. Indeed, the test can be fixed by enforcing the symbol implementation from our side.


My guess: the reason why it does not reproduce may be related to how header to inclusion is passed to scudo. Maybe @lntue and you are not using fullbuild?

@nickdesaulniers
Copy link
Member

Ah! I was reproducing on the buildbot, and was attaching gdb to spot a malloc that would fail.

Breakpoint 1, __GI___mmap64 (addr=0xffd7f7ee77ca, len=262144, prot=3, flags=50, fd=-1, offset=0)

I guess I didn't spot that 0xffd7f7ee77ca is not a multiple of the page size and that 50 is MAP_FIXED.

Anyways, bravo, nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants