Skip to content

Conversation

@brad0
Copy link
Contributor

@brad0 brad0 commented Dec 8, 2025

r13 does not provide the trap err.

@llvmbot
Copy link
Member

llvmbot commented Dec 8, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Brad Smith (brad0)

Changes

r13 does not provide the trap err.


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

2 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp (+7-2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h (+4)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 87a18b1120af6..37245c35cf919 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -1287,7 +1287,7 @@ uptr GetPageSize() {
 
 uptr ReadBinaryName(/*out*/ char *buf, uptr buf_len) {
 #  if SANITIZER_HAIKU
-  int cookie = 0;
+  int32_t cookie = 0;
   image_info info;
   const char *argv0 = "<UNKNOWN>";
   while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
@@ -1987,7 +1987,7 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
 #    elif SANITIZER_NETBSD
   uptr err = ucontext->uc_mcontext.__gregs[_REG_ERR];
 #    elif SANITIZER_HAIKU
-  uptr err = ucontext->uc_mcontext.r13;
+  uptr err = 0; // ucontext->uc_mcontext.r13;
 #    elif SANITIZER_SOLARIS && defined(__i386__)
   const int Err = 13;
   uptr err = ucontext->uc_mcontext.gregs[Err];
@@ -2617,6 +2617,11 @@ static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
   *pc = ucontext->uc_mcontext.mc_eip;
   *bp = ucontext->uc_mcontext.mc_ebp;
   *sp = ucontext->uc_mcontext.mc_esp;
+#    elif SANITIZER_HAIKU
+  ucontext_t *ucontext = (ucontext_t*)context;
+  *pc = ucontext->uc_mcontext.eip;
+  *bp = ucontext->uc_mcontext.ebp;
+  *sp = ucontext->uc_mcontext.esp;
 #    else
   ucontext_t *ucontext = (ucontext_t *)context;
 #      if SANITIZER_SOLARIS
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index 24966523f3a02..82f0da14f5efe 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -629,7 +629,11 @@ typedef unsigned long __sanitizer_sigset_t;
 #  elif SANITIZER_APPLE
 typedef unsigned __sanitizer_sigset_t;
 #  elif SANITIZER_HAIKU
+#   if defined(__x86_64__)
 typedef unsigned long __sanitizer_sigset_t;
+#   else
+typedef unsigned long long __sanitizer_sigset_t;
+#   endif
 #  elif SANITIZER_LINUX
 struct __sanitizer_sigset_t {
   // The size is determined by looking at sizeof of real sigset_t on linux.

@github-actions
Copy link

github-actions bot commented Dec 8, 2025

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions cpp,h -- compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h --diff_from_common_commit

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
index 090b42a92..cf3146737 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
@@ -1987,10 +1987,11 @@ SignalContext::WriteFlag SignalContext::GetWriteFlag() const {
 #    elif SANITIZER_NETBSD
   uptr err = ucontext->uc_mcontext.__gregs[_REG_ERR];
 #    elif SANITIZER_HAIKU
-  uptr err = 0;  // FIXME: ucontext->uc_mcontext.r13;
-                 // The err register was added on the main branch and not
-                 // available with the current release. To be reverted later.
-                 // https://github.com/haiku/haiku/commit/11adda21aa4e6b24f71a496868a44d7607bc3764
+  uptr err =
+      0;  // FIXME: ucontext->uc_mcontext.r13;
+          // The err register was added on the main branch and not
+          // available with the current release. To be reverted later.
+          // https://github.com/haiku/haiku/commit/11adda21aa4e6b24f71a496868a44d7607bc3764
 #    elif SANITIZER_SOLARIS && defined(__i386__)
   const int Err = 13;
   uptr err = ucontext->uc_mcontext.gregs[Err];
@@ -2621,7 +2622,7 @@ static void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) {
   *bp = ucontext->uc_mcontext.mc_ebp;
   *sp = ucontext->uc_mcontext.mc_esp;
 #    elif SANITIZER_HAIKU
-  ucontext_t *ucontext = (ucontext_t *)context;
+  ucontext_t* ucontext = (ucontext_t*)context;
   *pc = ucontext->uc_mcontext.eip;
   *bp = ucontext->uc_mcontext.ebp;
   *sp = ucontext->uc_mcontext.esp;

@brad0 brad0 force-pushed the compiler_rt_haiku branch from b8855b3 to f0fc74a Compare December 8, 2025 05:01
@brad0 brad0 requested a review from devnexen December 8, 2025 06:07
uptr err = ucontext->uc_mcontext.__gregs[_REG_ERR];
# elif SANITIZER_HAIKU
uptr err = ucontext->uc_mcontext.r13;
uptr err = 0; // ucontext->uc_mcontext.r13;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but does it work for 64 bits though (should I think) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The err register got added on the main branch, but isn't yet on the current Haiku release. See haiku/haiku@11adda2 for more info. We'll use the register when possible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh phewww :) might make sense to make a FIXME/TODO comment here then.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The err register got added on the main branch, but isn't yet on the current Haiku release.

oh phewww :) might make sense to make a FIXME/TODO comment here then.

Ohh, that makes more sense. Yes, a comment for reference would make more sense. Then some point down the road flipping that back around.

# if defined(__x86_64__)
typedef unsigned long __sanitizer_sigset_t;
# else
typedef unsigned long long __sanitizer_sigset_t;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unsigned long long should be the same as unsigned long on 64 bit, so this could be simplified to always use unsigned long long.

r13 does not provide the trap err.
@brad0 brad0 force-pushed the compiler_rt_haiku branch from f0fc74a to e520525 Compare December 9, 2025 21:26
@brad0
Copy link
Contributor Author

brad0 commented Dec 9, 2025

@devnexen @korli How does this look?

@brad0 brad0 requested review from jmairboeck and korli December 9, 2025 22:26
@korli
Copy link
Contributor

korli commented Dec 10, 2025

@devnexen @korli How does this look?

Thanks. LGTM!

@brad0 brad0 merged commit 62dbe57 into llvm:main Dec 10, 2025
8 of 10 checks passed
@brad0 brad0 deleted the compiler_rt_haiku branch December 10, 2025 08:10
@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 10, 2025

LLVM Buildbot has detected a new failure on builder openmp-offload-amdgpu-runtime-2 running on rocm-worker-hw-02 while building compiler-rt at step 2 "checkout".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/10/builds/18805

Here is the relevant piece of the build log for the reference
Step 2 (checkout) failure: update (failure)
git version 2.34.1
fatal: unable to access 'https://github.com/llvm/llvm-project.git/': Could not resolve host: github.com
fatal: unable to access 'https://github.com/llvm/llvm-project.git/': Could not resolve host: github.com

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 10, 2025

LLVM Buildbot has detected a new failure on builder amdgpu-offload-rhel-9-cmake-build-only running on rocm-docker-rhel-9 while building compiler-rt at step 2 "update-annotated-scripts".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/205/builds/30205

Here is the relevant piece of the build log for the reference
Step 2 (update-annotated-scripts) failure: update (failure)
git version 2.43.5
fatal: unable to access 'https://github.com/llvm/llvm-zorg.git/': Could not resolve host: github.com
fatal: unable to access 'https://github.com/llvm/llvm-zorg.git/': Could not resolve host: github.com

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 10, 2025

LLVM Buildbot has detected a new failure on builder amdgpu-offload-ubuntu-22-cmake-build-only running on rocm-docker-ubu-22 while building compiler-rt at step 2 "update-annotated-scripts".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/203/builds/31415

Here is the relevant piece of the build log for the reference
Step 2 (update-annotated-scripts) failure: update (failure)
git version 2.34.1
fatal: unable to access 'https://github.com/llvm/llvm-zorg.git/': Could not resolve host: github.com
fatal: unable to access 'https://github.com/llvm/llvm-zorg.git/': Could not resolve host: github.com

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 10, 2025

LLVM Buildbot has detected a new failure on builder amdgpu-offload-rhel-8-cmake-build-only running on rocm-docker-rhel-8 while building compiler-rt at step 2 "update-annotated-scripts".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/204/builds/30226

Here is the relevant piece of the build log for the reference
Step 2 (update-annotated-scripts) failure: update (failure)
git version 2.43.5
fatal: unable to access 'https://github.com/llvm/llvm-zorg.git/': Could not resolve host: github.com
fatal: unable to access 'https://github.com/llvm/llvm-zorg.git/': Could not resolve host: github.com

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 10, 2025

LLVM Buildbot has detected a new failure on builder hip-third-party-libs-test running on ext_buildbot_hw_05-hip-docker while building compiler-rt at step 2 "update-annotated-scripts".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/206/builds/10315

Here is the relevant piece of the build log for the reference
Step 2 (update-annotated-scripts) failure: update (failure)
git version 2.34.1
fatal: unable to access 'https://github.com/llvm/llvm-zorg.git/': Could not resolve host: github.com
fatal: unable to access 'https://github.com/llvm/llvm-zorg.git/': Could not resolve host: github.com

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 10, 2025

LLVM Buildbot has detected a new failure on builder openmp-offload-sles-build-only running on rocm-worker-hw-04-sles while building compiler-rt at step 2 "checkout".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/35443

Here is the relevant piece of the build log for the reference
Step 2 (checkout) failure: update (failure)
git version 2.35.3
fatal: unable to access 'https://github.com/llvm/llvm-project.git/': Could not resolve host: github.com
fatal: unable to access 'https://github.com/llvm/llvm-project.git/': Could not resolve host: github.com

dadra-oc pushed a commit to dadra-oc/llvm-project that referenced this pull request Dec 11, 2025
r13 does not provide the trap err.

Co-authored-by: Jerome Duval <jerome.duval@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants