Persona is no longer an option for authentication on BMO. For more details see Persona Deprecated.
Last Comment Bug 781457 - use of undeclared identifier '_Unwind_Backtrace'
: use of undeclared identifier '_Unwind_Backtrace'
Product: Core
Classification: Components
Component: XPCOM (show other bugs)
: Trunk
: All FreeBSD
: -- normal (vote)
: mozilla17
Assigned To: Jan Beich
: Nathan Froyd [:froydnj]
Depends on:
Blocks: 977457
  Show dependency treegraph
Reported: 2012-08-09 01:25 PDT by Jan Beich
Modified: 2014-02-26 20:14 PST (History)
2 users (show)
ryanvm: in‑testsuite-
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---

define _GNU_SOURCE for _Unwind_Backtrace (738 bytes, patch)
2012-08-09 01:28 PDT, Jan Beich
dbaron: review+
Details | Diff | Splinter Review
Bug 781457 - Define _GNU_SOURCE for _Unwind_Backtrace. r=dbaron (761 bytes, patch)
2012-08-09 22:26 PDT, Jan Beich
no flags Details | Diff | Splinter Review

Description Jan Beich 2012-08-09 01:25:59 PDT
User Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/17.0 Firefox/17.0
Build ID: 20120809002637

Steps to reproduce:

1. Installed libunwind
2. Tried to compile firefox with gcc42 or clang.

Actual results:

xpcom/base/nsStackWalk.cpp:1197:29: error: use of undeclared identifier '_Unwind_Backtrace'
    _Unwind_Reason_Code t = _Unwind_Backtrace(unwind_callback, &info);
1 error generated.

Expected results:

Build succesfully.
Comment 1 Jan Beich 2012-08-09 01:28:29 PDT
Created attachment 650465 [details] [diff] [review]
define _GNU_SOURCE for _Unwind_Backtrace
Comment 2 Jan Beich 2012-08-09 01:41:06 PDT
Comment on attachment 650465 [details] [diff] [review]
define _GNU_SOURCE for _Unwind_Backtrace

Unlike recent versions of GCC libunwind and libc++ put _Unwind_Backtrace under _GNU_SOURCE. However, configure script doesn't know this and just checks for the function in unwind.h irregardless of where it came from.
Comment 3 David Baron :dbaron: ⌚️UTC+9 (busy until November 7) 2012-08-09 11:36:30 PDT
How did configure detect the function's presence if it's conditional on _GNU_SOURCE?

(You deleted config.cache and reran configure when changing compilers, right?)
Comment 4 Jan Beich 2012-08-09 20:27:55 PDT
(In reply to David Baron [:dbaron] from comment #3)
> How did configure detect the function's presence if it's conditional on _GNU_SOURCE?

Configure script checks only header presence[1]. Then it goes to check libraries and finds that implicitly linked -lgcc_s provides _Unwind_Backtrace symbol.

$ env -i PATH=$PATH gmake conftest -f /dev/null
cc     conftest.c   -o conftest

$ cat conftest.c
#line 24094 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
    which can conflict with char _Unwind_Backtrace(); below.  */
#include <assert.h>
/* Override any gcc2 internal prototype to avoid an error.  */
/* We use char because int might match the return type of a gcc2
    builtin and then its argument prototype would still apply.  */
char _Unwind_Backtrace();

int main() {

/* The GNU C library defines this for functions which it implements
    to always fail with ENOSYS.  Some functions are actually named
    something starting with __ and the normal name is an alias.  */
#if defined (__stub__Unwind_Backtrace) || defined (__stub____Unwind_Backtrace)
choke me

; return 0; }

[1] more correct check would likely use AC_TRY_COMPILE, e.g.

dnl ========================================================
dnl = Support for gcc stack unwinding (from gcc 3.3)
dnl ========================================================
if test -z "$SKIP_LIBRARY_CHECKS"; then
    AC_MSG_CHECKING([for _Unwind_Backtrace in unwind.h])
    AC_TRY_COMPILE([#include <unwind.h>], [_Unwind_Backtrace(0,0)],
        AC_TRY_COMPILE([#define _GNU_SOURCE
                #include <unwind.h>], [_Unwind_Backtrace(0,0)],
            AC_MSG_RESULT([needs -D_GNU_SOURCE]),
            AC_MSG_RESULT([not found])))
Comment 5 Jan Beich 2012-08-09 20:46:29 PDT
On FreeBSD it usually is Blender port that pulls libunwind by default (CAMERATRACK option).
Comment 6 Jan Beich 2012-08-09 20:57:24 PDT
Note, clang has unwind.h since 3.1. The header is different from the one used by -stdlib=libc++, it doesn't need _GNU_SOURCE.
Comment 7 David Baron :dbaron: ⌚️UTC+9 (busy until November 7) 2012-08-09 21:59:10 PDT
Comment on attachment 650465 [details] [diff] [review]
define _GNU_SOURCE for _Unwind_Backtrace

Comment 8 Jan Beich 2012-08-09 22:26:05 PDT
Created attachment 650792 [details] [diff] [review]
Bug 781457 - Define _GNU_SOURCE for _Unwind_Backtrace. r=dbaron
Comment 10 Ryan VanderMeulen [:RyanVM] 2012-08-11 19:56:41 PDT

Note You need to log in before you can comment on or make changes to this bug.