🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.kylix.language.cpp
1 messages
1 total messages Started by Dave Devlin Tue, 06 Jul 2004 16:43
Exception handling in shared object
#4
Author: 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");
}
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads