🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.kylix.language.cpp
Article #4

Exception handling in shared object

#4
From: Dave Devlin
Date: Tue, 06 Jul 2004 16:43
55 lines
2270 bytes
Exception handling is crucial to our application, but I have a 
problem when using try/catch in Kylix-built C++ shared objects. 
If an exception occurs, execution enters the catch block, but 
then the program seg faults and terminates immediately. If there 
is a function call in the catch block, the seg fault occurs 
during the function call set-up. If there are no function calls, 
the seg fault occurs in the stack clean-up at the end of the 
catch block. Stepping through the assembly code, it appears that the bpx register gets messed up in libborcrtl.so.

Has anyone found a fix or workaround for this problem? It only 
occurs in shared objects.

The following simple program works correctly using g++, but fails using Kylix.

Thanks very much to anyone who can help, even if it's just to 
say "there is no fix".
- Dave Devlin

*** Here's my main program: ***

#ifdef __BORLANDC__
extern "C" __declspec(dllexport) void SharedObjFunc();
#else
extern "C" void SharedObjFunc();
#endif

int main(void)
{
	SharedObjFunc();
	return 0;
}

*** Here's my shared object: ***

#include <stdio.h>

#ifdef __BORLANDC__
extern "C" __declspec(dllexport) void SharedObjFunc()
#define EXPORT_FUNC   
#else
extern "C" void SharedObjFunc()
#endif
{
	try
	{
		printf("Throwing...\n");
		throw 1;
	}
	catch(...)
	{
		printf("...in catch. Kylix does not get here\n");
	}
	printf("...after catch. Kylix does not get here.\n");
}
Technical Details
Message-ID: <40ead6b9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10ed86,b8bd96ab32b81759,start
X-Google-Attributes: gid10ed86,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Dave Devlin" <d.devlin44@sympatico.ca>
Sender: "Dave Devlin" <d.devlin44@sympatico.ca>
Reply-To: "Dave Devlin" <d.devlin44@sympatico.ca>
Subject: Exception handling in shared object
Newsgroups: borland.public.kylix.language.cpp
X-User-Info: 64.230.0.147     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <40ead6b9$1@newsgroups.borland.com>
Date: 6 Jul 2004 09:43:37 -0700
X-Trace: newsgroups.borland.com 1089132217 207.105.83.66 (6 Jul 2004 09:43:37 -0700)
Lines: 56
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail