[libunwind] [libunwind] Fix running tests with MSan (PR #67860)

Louis Dionne via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 10 15:50:50 PDT 2023


================
@@ -115,6 +121,18 @@ extern int unw_set_reg(unw_cursor_t *, unw_regnum_t, unw_word_t) LIBUNWIND_AVAIL
 extern int unw_set_fpreg(unw_cursor_t *, unw_regnum_t, unw_fpreg_t)  LIBUNWIND_AVAIL;
 extern int unw_resume(unw_cursor_t *) LIBUNWIND_AVAIL;
 
+#ifdef LIBUNWIND_HAVE_MSAN
+// unw_getcontext is implemented in assembly so it is rather difficult to
+// mark the MSan shadow as initialized from within the function. Instead we
+// use a macro wrapper when compiling with MSan to avoid false-positives.
+#define unw_getcontext(context)                                                \
----------------
ldionne wrote:

I think what I had in mind was something like:

```
extern "C" int __unw_getcontext(unw_context_t *);

inline int unw_getcontext(unw_context_t *ctx) {
  // do stuff
  return __unw_getcontext(ctx);
}
```

I am having a bit of trouble tracking down how `unw_getcontext` is implemented right now, but IIUC it's only an alias to `__unw_getcontext`, is that right? If so, I think the `inline` approach here would work, I think?

https://github.com/llvm/llvm-project/pull/67860


More information about the cfe-commits mailing list