From owner-freebsd-hackers@FreeBSD.ORG Sat Jan 17 23:41:57 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 106C3106566B for ; Sat, 17 Jan 2009 23:41:57 +0000 (UTC) (envelope-from xorquewasp@googlemail.com) Received: from ey-out-2122.google.com (ey-out-2122.google.com [74.125.78.25]) by mx1.freebsd.org (Postfix) with ESMTP id 9800D8FC08 for ; Sat, 17 Jan 2009 23:41:56 +0000 (UTC) (envelope-from xorquewasp@googlemail.com) Received: by ey-out-2122.google.com with SMTP id d26so236787eyd.7 for ; Sat, 17 Jan 2009 15:41:55 -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:subject :message-id:mime-version:content-type:content-disposition; bh=WPeDrc+7sbkuCWW4ge7jCCFycSdKRN5v4Z1V18MTV/I=; b=JA/e10lyy8/xKZXJzC5fO1bcb4TbSfgj2B9D+RJG0ZXGLMVOCXDjSCviCZbZqhYxFs ldbnmWdGi9PWJnLb2eEuD3Szo0M7buuMuIrV01Sr+aDtR8KlsuA/SzyEHoQk5SPawMWL CggLIAd9mcLnYqCo7mCrdRvDlr6zCLyx6U200= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=date:from:to:subject:message-id:mime-version:content-type :content-disposition; b=Wm/VGANeomFu/X5cXJkdRpn2Me57KGv3Ky71+121O+1fGjTIlLP6P4GKG/d6kMP70C uFRgKk5xBWnpCTgMvzcL32CmaLLmHZqDUQPsE46Q8g8QfEXmU0nCrAgG2Dbj97/hAXHL ZcGoOXRhDN4XpFHboOpH/CVvpZvt2RnwJn3rY= Received: by 10.210.61.8 with SMTP id j8mr5154989eba.45.1232234046837; Sat, 17 Jan 2009 15:14:06 -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 t2sm4950499gve.26.2009.01.17.15.14.06 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 17 Jan 2009 15:14:06 -0800 (PST) Received: by logik.internal.network (Postfix, from userid 11001) id 045815C2B; Sat, 17 Jan 2009 23:14:04 +0000 (UTC) Date: Sat, 17 Jan 2009 23:14:04 +0000 From: xorquewasp@googlemail.com To: freebsd-hackers@freebsd.org Message-ID: <20090117231404.GB77134@logik.internal.network> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: 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: Sat, 17 Jan 2009 23:41:58 -0000 Hello. I have some C code that's compiled with -fexceptions using the lang/gnat-gcc43 port. I'm on 6.4-RELEASE-p2. A function c_function in the C code takes a callback as an argument. I'm passing this function the address of a function ext_function defined in another language (Ada, to be precise, but it seems to happen with C++ too). The main body of my program is written in this language so C is effectively the "foreign" code (whatever). If ext_function raises an exception, the exception is NOT propagated through the C code, the process simply exits. To clarify: 1. Ada_program_main calls c_function, passing ext_function as argument. 2. c_function calls ext_function. 3. ext_function raises exception. 4. process exits In this case, the C code lives inside a dynamic library, which is linked against /usr/local/lib/gcc-4.3.2/libgcc_s.so (I never specified this explicity, I'm assuming -fexceptions causes this). If I statically link the C code (so libgcc_s.so isn't involved, I think), the exception is propagated correctly. 1. Ada_program_main calls c_function, passing ext_function as argument. 2. c_function calls ext_function. 3. ext_function raises exception. 4. stack unwinds back to Ada_program_main. 5. Ada_program_main handles exception. Why is it that the code can't unwind the call stack correctly? Is this a bug? The same code seems to work correctly on Debian Lenny with the same compiler. Any help would be appreciated. xw