| 1 | // RUN: %clangxx_msan -O0 %s -o %t && %run %t |
| 2 | |
| 3 | #include <assert.h> |
| 4 | #include <execinfo.h> |
| 5 | #include <stdio.h> |
| 6 | #include <string.h> |
| 7 | #include <stdlib.h> |
| 8 | |
| 9 | __attribute__((noinline)) |
| 10 | void f() { |
| 11 | void *buf[10]; |
| 12 | int sz = backtrace(array: buf, size: sizeof(buf) / sizeof(*buf)); |
| 13 | assert(sz > 0); |
| 14 | for (int i = 0; i < sz; ++i) |
| 15 | if (!buf[i]) { |
| 16 | #if defined(__s390x__) |
| 17 | // backtrace() may return a bogus trailing NULL on s390x. |
| 18 | if (i == sz - 1) |
| 19 | continue; |
| 20 | #endif |
| 21 | exit(status: 1); |
| 22 | } |
| 23 | char **s = backtrace_symbols(array: buf, size: sz); |
| 24 | assert(s != 0); |
| 25 | for (int i = 0; i < sz; ++i) |
| 26 | printf(format: "%d\n" , (int)strlen(s: s[i])); |
| 27 | } |
| 28 | |
| 29 | int main(void) { |
| 30 | f(); |
| 31 | return 0; |
| 32 | } |
| 33 | |