From owner-freebsd-hackers@FreeBSD.ORG Sun Jan 18 07:19:28 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3CA30106566B for ; Sun, 18 Jan 2009 07:19:28 +0000 (UTC) (envelope-from xorquewasp@googlemail.com) Received: from mail-ew0-f13.google.com (mail-ew0-f13.google.com [209.85.219.13]) by mx1.freebsd.org (Postfix) with ESMTP id 996228FC2F for ; Sun, 18 Jan 2009 07:19:27 +0000 (UTC) (envelope-from xorquewasp@googlemail.com) Received: by ewy6 with SMTP id 6so71450ewy.19 for ; Sat, 17 Jan 2009 23:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:received:date:from:to:cc :subject:message-id:references:mime-version:content-type :content-disposition:in-reply-to; bh=vMVpg8iLnylecpPfGX0xjac3FJ54/qwK5fomgeuXzvY=; b=oQo8igbfeWeCVpNRAFOBmE2sR/L2CdrHJ+uSwLDI2fAyauWYevOP6Ohb5Pw9auOUjY LXTH/Ej5E2wHIynRi0rbolxqk96my2nwC1RINSaiosNEKX8oNxvO9RoU22J4QymPpfmj 6Y5IxCO8HHNz5FP0mF1SR5orOtMYcqJGHMtAc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to; b=j1InTGDtd8UXmw8tR70uV6f4uEA8Khi++ms6PpXAGTEksW/Mr1bZEg6ghOvOlHf8al k6U+AQH8vG+DheOtxH+crfEalwjJ1VI8O2m6DBkR90sx8Yu79+yNDlB6TdRr4mPmgvVN dxd7b6JD86oduFsTpj3xYPUi5pBdKGwJwkBzo= Received: by 10.210.35.17 with SMTP id i17mr5526282ebi.165.1232263166541; Sat, 17 Jan 2009 23:19:26 -0800 (PST) Received: from logik.internal.network (81-86-41-187.dsl.pipex.com [81.86.41.187]) by mx.google.com with ESMTPS id p10sm5398865gvf.25.2009.01.17.23.19.25 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 17 Jan 2009 23:19:26 -0800 (PST) Received: by logik.internal.network (Postfix, from userid 11001) id 33C905C2B; Sun, 18 Jan 2009 07:19:24 +0000 (UTC) Date: Sun, 18 Jan 2009 07:19:24 +0000 From: xorquewasp@googlemail.com To: Christoph Mallon Message-ID: <20090118071924.GA43496@logik.internal.network> References: <20090117231404.GB77134@logik.internal.network> <4972CEB7.40505@gmx.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4972CEB7.40505@gmx.de> Cc: freebsd-hackers@freebsd.org Subject: Re: gcc 4.3.2 libgcc_s.so exception handling broken? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 Jan 2009 07:19:28 -0000 On 2009-01-18 07:39:51, Christoph Mallon wrote: > > Are more C functions involved? E.g. is the function pointer passed to > qsort(), which lives in libc, which is not compiled with -fexceptions. > Look at the stack trace when the exception occurs. In gdb you can use the > command "catch throw" (sic) to break when an exception gets thrown. > Conversely you can break at the catcher with "catch catch" (if it gets this > far). Unfortunately not. That was the first thing I looked at. Here's the complete test: /* c_function.c */ #include void c_function (void (*func)(int x)) { printf ("-- %s enter\n", __func__); func (23); printf ("-- %s exit\n", __func__); } -- ada_main.adb with interfaces.c; with ada.text_io; procedure ada_main is package c renames interfaces.c; test_error : exception; procedure ext_function (x : in c.int) is begin ada.text_io.put_line ("-- ext_function " & c.int'image (x)); raise test_error; end ext_function; procedure c_function (process : access procedure (x : in c.int)); pragma import (c, c_function, "c_function"); begin ada.text_io.put_line ("-- ada_main entry"); c_function (ext_function'access); exception when test_error => ada.text_io.put_line ("-- ada_main caught test_error"); end ada_main; Compilation: gcc43 -o c_function.o -c c_function.c -fPIC -fexceptions -g -W -Werror -Wall -std=c99 -pedantic-errors -Wno-unused-parameter gcc43 -shared -Wl,-soname,c_function.so -o c_function.so c_function.o -lc gcc43 -o ada_main.o -c ada_main.adb -g -fstack-check -gnatwaleFG -gnatVa -gnato -gnata gnatbind ada_main.ali gnatlink -o main-dynamic ada_main.ali c_function.so gnatbind ada_main.ali gnatlink -o main-static ada_main.ali c_function.o $ LD_LIBRARY_PATH=. ldd c_function.so c_function.so: libc.so.6 => /lib/libc.so.6 (0x2807d000) libgcc_s.so.1 => /usr/local/lib/gcc-4.2.3/libgcc_s.so.1 (0x28170000) Test: $ ./main-static -- ada_main entry -- c_function enter -- ext_function 23 -- ada_main caught test_error $ LD_LIBRARY_PATH=. ./main-dynamic -- ada_main entry -- c_function enter -- ext_function 23 raised ADA_MAIN.TEST_ERROR : ada_main.adb:15 $ LD_LIBRARY_PATH=. gdb68 ./main-dynamic (gdb) catch exception Catchpoint 1: all Ada exceptions (gdb) b __gnat_os_exit Breakpoint 2 at 0x805851b: file adaint.c, line 2116. (gdb) r Catchpoint 1, ADA_MAIN.TEST_ERROR at 0x08049cda in ada_main.ext_function (x=23) at ada_main.adb:15 15 raise test_error; (gdb) bt #0 <__gnat_debug_raise_exception> (e=0x8061168) at s-except.adb:48 #1 0x0804b620 in <__gnat_raise_nodefer_with_msg> (e=0x8061168) at a-except.adb:830 #2 0x0804b698 in <__gnat_raise_exception> (e=0x8061168, message=0x8061168) at a-except.adb:870 #3 0x08049cda in ada_main.ext_function (x=23) at ada_main.adb:15 #4 0x280927ae in c_function (func=0x8049bf8 ) at c_function.c:9 #5 0x08049b5c in ada_main () at ada_main.adb:24 (gdb) c Breakpoint 2, __gnat_os_exit (status=1) at adaint.c:2116 (gdb) bt #0 __gnat_os_exit (status=1) at adaint.c:2116 #1 0x0805a41e in __gnat_unhandled_terminate () at raise.c:78 #2 0x0805a1f1 in <__gnat_last_chance_handler> (except=@0x8071000) at a-elchha.adb:138 #3 0x0804ae14 in ada.exceptions.exception_traces.unhandled_exception_terminate () at a-exextr.adb:175 #4 0x0804aad2 in ada.exceptions.exception_propagation.cleanupunwind_handler (uw_version=1, uw_phases=10, uw_eclass=5138137877735301376, uw_exception=0xa, uw_context=3217024852, uw_argument=0, =134587758) at a-exexpr.adb:369 #5 0x0805c282 in _Unwind_ForcedUnwind_Phase2 (exc=0x806f000, context=0xbfbfe754) at ../.././..//gcc-4.3.2/libgcc/../gcc/unwind.inc:168 #6 0x0805c4d6 in _Unwind_Resume (exc=0x806f000) at ../.././..//gcc-4.3.2/libgcc/../gcc/unwind.inc:237 #7 0x08049cfa in ada_main.ext_function (x=23) at ada_main.adb:16 #8 0x280927ae in c_function (func=0x8049bf8 ) at c_function.c:9 #9 0x08049b5c in ada_main () at ada_main.adb:24