By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,847 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

C program can't catch exception from C++

P: n/a
I am building a NSS module on Solaris 10 64bit (amd64). It is a dynamic
linked library to be invoked by the other programs like the system
command ps.

The dynamic linked library is build on C++. Exception are thrown when
errors are detected. The exceptions actually are handled inside the
dynamic linked library. It is found that the exception can't be caught
when the DLL is invoked by programs like the ps command and lead to
segmentation fault. Yet, the exceptions can be caught when the DLL is
invoked my testing C++ program.

I have try the -fexceptions option in GCC, the problem still exists.

Can anyone give me some suggestions?

Thanks

Dec 8 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Al***********@gmail.com wrote:
The dynamic linked library is build on C++. Exception are thrown when
errors are detected. The exceptions actually are handled inside the
dynamic linked library. It is found that the exception can't be caught
when the DLL is invoked by programs like the ps command and lead to
segmentation fault. Yet, the exceptions can be caught when the DLL is
invoked my testing C++ program.

I have try the -fexceptions option in GCC, the problem still exists.


What makes you think that a C program can catch or propagate C++
exceptions?

Dec 8 '05 #2

P: n/a

Al***********@gmail.com wrote:
I am building a NSS module on Solaris 10 64bit (amd64). It is a dynamic
linked library to be invoked by the other programs like the system
command ps.

The dynamic linked library is build on C++. Exception are thrown when
errors are detected. The exceptions actually are handled inside the
dynamic linked library. It is found that the exception can't be caught
when the DLL is invoked by programs like the ps command and lead to
segmentation fault. Yet, the exceptions can be caught when the DLL is
invoked my testing C++ program.


The issue is possibly that the C main() doesn't call the C++ library
initializer needed to catch exceptions. Your environment may include
documentation on how to call this initializer. It's not on-topic here.

HTH,
Michiel Salters

Dec 8 '05 #3

P: n/a
By using LD_DEBUG, I find that a symbol binds to /usr/amd64/libc.so.1
is stead of /usr/sfw/lib/libgcc_s.so.1

25825: 1: symbol=_Unwind_RaiseException; lookup in
file=/lib/64/libc.so.1 [ ELF ]
25825: 1: binding file=/usr/share/centrifydc/lib/amd64/libstdc++.so.6
(0xfffffd7ffec1c71e:0xdc71e) at plt[502]:full to file=/lib/64/libc.so.1
(0xfffffd7fff1ac4b3:0xcc4b3): symbol `_Unwind_RaiseException'
If use LD_PRELOAD to preload /usr/sfw/lib/libgcc_s.so.1, it works fine.

Can I control the order look up symbols from libraries? I have already
use -R option.

Dec 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.