[Bug 207325] projects/clang380-import for TARGET_ARCH=powerpc : c++ exceptions cause SEGV (9 line program)

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Fri Feb 19 06:41:01 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=207325

            Bug ID: 207325
           Summary: projects/clang380-import for TARGET_ARCH=powerpc : c++
                    exceptions cause SEGV (9 line program)
           Product: Base System
           Version: 11.0-CURRENT
          Hardware: ppc
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: markmi at dsl-only.net

When run the following 9 or so program compiled by clang 3.8.0 (from
project/clang380import -r295601) for TARGET_ARCH=powerpc gets a SEGV:

#include <exception>

int main(void)
{
    try { throw std::exception(); }
    catch (std::exception& e) {} // same result without &
    return 0;
}

(This simplifies what I found in trying to build and use some ports. For
example, it blocks using "kyua test -k /usr/tests/Kyuafile", which gets a SEGV
and aborts.)

# clang++ -g -std=c++11 -Wall -Wpedantic exception_test.cpp
# ./a.out
Segmentation fault (core dumped)

Trying under gdb:
. . .
(gdb) run
Starting program: /root/c_tests/a.out 

Program received signal SIGSEGV, Segmentation fault.
_Unwind_GetGR (context=0xffffd5a0, index=<optimized out>) at
/usr/src/gnu/lib/libgcc/../../../contrib/gcc/unwind-dw2.c:177
177         return * (_Unwind_Ptr *) ptr;
(gdb) bt
#0  _Unwind_GetGR (context=0xffffd5a0, index=<optimized out>) at
/usr/src/gnu/lib/libgcc/../../../contrib/gcc/unwind-dw2.c:177
#1  _Unwind_GetPtr (context=0xffffd5a0, index=<optimized out>) at
/usr/src/gnu/lib/libgcc/../../../contrib/gcc/unwind-dw2.c:188
#2  uw_update_context (context=0xffffd5a0, fs=0xffffd0e0) at
/usr/src/gnu/lib/libgcc/../../../contrib/gcc/unwind-dw2.c:1370
#3  _Unwind_RaiseException (exc=<optimized out>) at
/usr/src/gnu/lib/libgcc/../../../contrib/gcc/unwind.inc:126
#4  0x4192970c in throw_exception (ex=<optimized out>) at
/usr/src/lib/libcxxrt/../../contrib/libcxxrt/exception.cc:751
#5  __cxa_throw (thrown_exception=<optimized out>, tinfo=<optimized out>,
dest=<optimized out>) at
/usr/src/lib/libcxxrt/../../contrib/libcxxrt/exception.cc:778
#6  0x00000000 in ?? ()

Context details:

# freebsd-version -ku; uname -aKU
11.0-CURRENT
11.0-CURRENT
FreeBSD FBSDG4C1 11.0-CURRENT FreeBSD 11.0-CURRENT #4 r295601M: Sun Feb 14
15:49:49 PST 2016    
markmi at FreeBSDx64:/usr/obj/clang_gcc421/powerpc.powerpc/usr/src/sys/GENERICvtsc-NODEBUG
 powerpc 1100097 1100097

buildkernel is via gcc 4.2.1
buildworld is via clang 3.8.0

(I've been experimenting with and submitting issues from this environment, an
arm
rip2 environment (clang 3.8.0 for both buildworld and buildkernel), and
powerpc64 (via powerpc64-gcc, not clang). So there are some fixes/workarounds
for various issues in my environment.)

# svnlite status /usr/src/
?       /usr/src/.snap
M       /usr/src/contrib/libc++/include/__config
M       /usr/src/contrib/libcxxrt/guard.cc
M       /usr/src/contrib/llvm/tools/clang/lib/CodeGen/TargetInfo.cpp
M       /usr/src/lib/csu/powerpc64/Makefile
?       /usr/src/restoresymtable
?       /usr/src/sys/arm/conf/RPI2-NODBG
M       /usr/src/sys/boot/ofw/Makefile.inc
M       /usr/src/sys/boot/powerpc/Makefile
M       /usr/src/sys/boot/powerpc/Makefile.inc
M       /usr/src/sys/boot/uboot/Makefile.inc
M       /usr/src/sys/conf/Makefile.powerpc
M       /usr/src/sys/conf/kern.mk
M       /usr/src/sys/conf/kmod.mk
?       /usr/src/sys/powerpc/conf/GENERIC64-NODBG
?       /usr/src/sys/powerpc/conf/GENERIC64vtsc
?       /usr/src/sys/powerpc/conf/GENERIC64vtsc-NODEBUG
?       /usr/src/sys/powerpc/conf/GENERICvtsc
?       /usr/src/sys/powerpc/conf/GENERICvtsc-NODEBUG
M       /usr/src/sys/powerpc/ofw/ofw_machdep.c
M       /usr/src/sys/powerpc/powerpc/exec_machdep.c

For TARGET_ARCH=powerpc the signal delivery has a "red zone" added to deal with
clang 3.8.0 moving the stack pointer late on entry to functions and early on
exit from functions compared to the ABI. And there is a va_arg fix for
va_list's gpr and fpr value handling to be sure the overflow area is used when
it should be. There is tracking of command line option changes.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list