BUG #18899: FreeBSD, assembly by means of GCC with ASAN ends with error: undef reference to backtrace_symbols_fd
От | PG Bug reporting form |
---|---|
Тема | BUG #18899: FreeBSD, assembly by means of GCC with ASAN ends with error: undef reference to backtrace_symbols_fd |
Дата | |
Msg-id | 18899-47cd40db80d699d8@postgresql.org обсуждение исходный текст |
Ответы |
Re: BUG #18899: FreeBSD, assembly by means of GCC with ASAN ends with error: undef reference to backtrace_symbols_fd
|
Список | pgsql-bugs |
The following bug has been logged on the website: Bug reference: 18899 Logged by: Alexander Mitrokhin Email address: a.mitrokhin@postgrespro.ru PostgreSQL version: 17.4 Operating system: FreeBSD 14.2 Description: Hello. After `configure' we have $BUILDDIR/src/pg_config.h: /* Define to 1 if you have the `backtrace_symbols' function. */ #define HAVE_BACKTRACE_SYMBOLS 1 When checking, such configtest.c is used: extern char backtrace_symbols (); int main () { return backtrace_symbols (); } With ASAN, configtest.c is built without the need for some additional libraries, because `backtrace_symbols' defined in /usr/local/lib/gcc13/libasan.so.8. $ nm -D /usr/local/lib/gcc13/libasan.so.8 | grep backtrace_symbols 000000000007e6c0 T __interceptor_backtrace_symbols 000000000007e6c0 T backtrace_symbols But when linking src/backend/postgres we will get: src/backend/utils/error/assert.c:53:(.text+0x19a): undefined reference to `backtrace_symbols_fd' 46 /* If we have support for it, dump a simple backtrace */ 47 #ifdef HAVE_BACKTRACE_SYMBOLS 48 { 49 void *buf[100]; 50 int nframes; 51 52 nframes = backtrace(buf, lengthof(buf)); 53 backtrace_symbols_fd(buf, nframes, fileno(stderr)); 54 } 55 #endif The `configure' code that checks whether it is necessary to use the libexecinfo: for ac_lib in '' execinfo; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi if ac_fn_c_try_link "$LINENO"; then ac_cv_search_backtrace_symbols=$ac_res fi if ${ac_cv_search_backtrace_symbols+:} false; then break fi done ... LIBS=$ac_func_search_save_LIBS With ASAN, the check to -lexecinfo does not reach and this library is not added to LIBS. PS: This corrects the problem for me: diff --git a/configure.ac b/configure.ac index 22441728459..fcf9c00c590 100644 --- a/configure.ac +++ b/configure.ac @@ -1373,7 +1373,7 @@ AC_SEARCH_LIBS(clock_gettime, rt) # Cygwin: AC_SEARCH_LIBS(shmget, cygipc) # *BSD: -AC_SEARCH_LIBS(backtrace_symbols, execinfo) +AC_SEARCH_LIBS(backtrace_symbols_fd, execinfo) AC_SEARCH_LIBS(pthread_barrier_wait, pthread) /foo
В списке pgsql-bugs по дате отправления: