* Exception handling in GCC 3.0.1 on AIX platform
@ 2001-09-13 5:03 Dmitry Dolgopolov
2001-09-13 9:48 ` David Edelsohn
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Dolgopolov @ 2001-09-13 5:03 UTC (permalink / raw)
To: David Edelsohn; +Cc: gcc
Hello,
Sometime ago I wrote about problems encountered with exceptions
handling in GCC 3.0.1 on AIX 4.3.2.0 platform. Specifically, when
exception is generated in a dynamicaly loaded module and tried to
be catched in the program that loads that module. Following are the
sample programs:
---
// testmain.cpp
#include <iostream>
#include <dlfcn.h>
int main() {
void* handle = dlopen("./libshared.a", RTLD_LAZY | RTLD_GLOBAL);
if (!handle) {
std::cerr << "main:: Error during dlopen()" << std::endl;
return 0;
}
void* symbol = dlsym(handle, "some_function");
if (symbol) try {
((void (*)())symbol)();
} catch (const std::string&) {
std::cerr << "main:: Exception catched" << std::endl;
} else {
std::cerr << "main:: Error during dlsym()" << std::endl;
}
dlclose(handle);
return 0;
}
---
// sharedlibrary.cpp
#include <iostream>
#include <dlfcn.h>
extern "C"
void some_function() {
std::cerr << "some_function:: trace point" << std::endl;
void* handle = dlopen("./libdeep.a", RTLD_LAZY | RTLD_GLOBAL);
if (!handle) {
std::cerr << "some_function:: Error during dlopen()" << std::endl;
return;
}
void* symbol = dlsym(handle, "deep_function");
if (symbol) try {
((void (*)())symbol)();
} catch (const std::string&) {
std::cerr << "some_function:: Exception catched" << std::endl;
} else {
std::cerr << "some_function:: Error during dlsym()" << std::endl;
}
dlclose(handle);
}
---
// deeplibrary.cpp
#include <iostream>
extern "C"
void deep_function() {
std::cerr << "deep_function:: trace point" << std::endl;
throw std::string("exception");
}
---
Following commands were used during build:
c++ -pthread -Wl,-brtl -Wl,-bh:8 -o testmain testmain.cpp
c++ -pthread -shared -Wl,-G -Wl,-bh:8 -o libshared.a sharedlibrary.cpp
c++ -pthread -shared -Wl,-G -Wl,-bh:8 -o libdeep.a deeplibrary.cpp
Then
chmod a+x,o-r *.a
slibclean
Results of execution are as follows:
# ./testmain
some_function:: trace point
deep_function:: trace point
IOT/Abort trap (core dumped)
--
Best regards,
Dmitry Dolgopolov mailto:d.dolgopolov@websci.ru
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Exception handling in GCC 3.0.1 on AIX platform
2001-09-13 5:03 Exception handling in GCC 3.0.1 on AIX platform Dmitry Dolgopolov
@ 2001-09-13 9:48 ` David Edelsohn
0 siblings, 0 replies; 4+ messages in thread
From: David Edelsohn @ 2001-09-13 9:48 UTC (permalink / raw)
To: Dmitry Dolgopolov; +Cc: gcc
You sent the same bug report last week. Please stop sending the
same information.
Thanks, David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Exception handling in GCC 3.0.1 on AIX platform
2001-09-05 20:53 Dmitry Dolgopolov
@ 2001-09-05 21:02 ` David Edelsohn
0 siblings, 0 replies; 4+ messages in thread
From: David Edelsohn @ 2001-09-05 21:02 UTC (permalink / raw)
To: Dmitry Dolgopolov; +Cc: gcc
At the moment, shared objects using exceptions need to have their
mode set "chmod o-r" so that they are loaded into the process-private
segment.
BTW, if you are going to bother using -G/-brtl, you might as well
just use the ".so" extension for the file type.
David
^ permalink raw reply [flat|nested] 4+ messages in thread
* Exception handling in GCC 3.0.1 on AIX platform
@ 2001-09-05 20:53 Dmitry Dolgopolov
2001-09-05 21:02 ` David Edelsohn
0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Dolgopolov @ 2001-09-05 20:53 UTC (permalink / raw)
To: David Edelsohn; +Cc: gcc
Hello,
We encountered the problem with exceptions handling in GCC 3.0.1 on
AIX 4.3.2.0 platform. Specifically, when exception is generated in
a dynamicaly loaded module and tried to be catched in the program
that loads that module. Following are the sample programs:
---
// testmain.cpp
#include <iostream>
#include <dlfcn.h>
int main() {
void* handle = dlopen("./libshared.a", RTLD_LAZY | RTLD_GLOBAL);
if (!handle) {
std::cerr << "main:: Error during dlopen()" << std::endl;
return 0;
}
void* symbol = dlsym(handle, "some_function");
if (symbol) try {
((void (*)())symbol)();
} catch (const std::string&) {
std::cerr << "main:: Exception catched" << std::endl;
} else {
std::cerr << "main:: Error during dlsym()" << std::endl;
}
dlclose(handle);
return 0;
}
---
// sharedlibrary.cpp
#include <iostream>
#include <dlfcn.h>
extern "C"
void some_function() {
std::cerr << "some_function:: trace point" << std::endl;
void* handle = dlopen("./libdeep.a", RTLD_LAZY | RTLD_GLOBAL);
if (!handle) {
std::cerr << "some_function:: Error during dlopen()" << std::endl;
return;
}
void* symbol = dlsym(handle, "deep_function");
if (symbol) try {
((void (*)())symbol)();
} catch (const std::string&) {
std::cerr << "some_function:: Exception catched" << std::endl;
} else {
std::cerr << "some_function:: Error during dlsym()" << std::endl;
}
dlclose(handle);
}
---
// deeplibrary.cpp
#include <iostream>
extern "C"
void deep_function() {
std::cerr << "deep_function:: trace point" << std::endl;
throw std::string("exception");
}
---
Following commands were used during build:
c++ -pthread -Wl,-brtl -Wl,-bh:8 -o testmain testmain.cpp
c++ -pthread -shared -Wl,-G -Wl,-bh:8 -o libshared.a sharedlibrary.cpp
c++ -pthread -shared -Wl,-G -Wl,-bh:8 -o libdeep.a deeplibrary.cpp
Results of execution are as follows:
# ./testmain
some_function:: trace point
deep_function:: trace point
IOT/Abort trap (core dumped)
--
Best regards,
Dmitry Dolgopolov mailto:d.dolgopolov@websci.ru
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-09-13 9:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-09-13 5:03 Exception handling in GCC 3.0.1 on AIX platform Dmitry Dolgopolov
2001-09-13 9:48 ` David Edelsohn
-- strict thread matches above, loose matches on Subject: below --
2001-09-05 20:53 Dmitry Dolgopolov
2001-09-05 21:02 ` David Edelsohn
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).