Hi Luigi, I'm still facing the same issue to handle QL exceptions on Unix, I tried to debug the program but I'd like to ask you some help. I tried to compile with the last version of GCC and last version of Quantlib and nothing works; still the same core dump. I tried to compile with other options like -lstdc++ or shared-libgcc but still the same core dump. I tried a main source code like: int main() { try { QL_REQUIRE(1 < 0.0,"exception"); } catch (std::exception& e) { std::cout<<"in exception"<<std::endl; std::cerr << e.what() << std::endl; return 1; } } and here it works, it gives me the "in exception exception". Now in debug mode I see that the program goes until \ql\errors.hpp at this level: class Error : public std::exception { public: explicit Error(const std::string& what = "") : message(what) {} ~Error() throw() {} and here it crashes (certainly outside of errors.hpp) It's now getting hard to debug and I 'd like to know if you have an idea on what I could do to follow in analysing the problem and solve it. Thanks for your help Xavier Xavier ABULKER To: Luigi Ballabio <[hidden email]> 21/05/2003 cc: [hidden email], 15:27 [hidden email] Subject: Re: [Quantlib-users] exception handling on Unix (Document link: Xavier ABULKER) Hi Luigi, this second example gives me the error: " ~/QuantLib-0.3.1/Examples/EuropeanOption> make source='EuropeanOption.cpp' object='EuropeanOption.o' libtool=no \ depfile='.deps/EuropeanOption.Po' tmpdepfile='.deps/EuropeanOption.TPo' \ depmode=gcc /bin/bash ../../config/depcomp \ g++ -DHAVE_CONFIG_H -I. -I. -I../../ql -I../.. -I../.. -c -o EuropeanOption.o `test -f 'EuropeanOption.cpp' || echo './' `EuropeanOption.cpp EuropeanOption.cpp: In function `int main()': EuropeanOption.cpp:29: parse error before `)' EuropeanOption.cpp:32: no matching function for call to `QuantLib::Instruments::VanillaOption::VanillaOption (QuantLib::Option::Type, QuantLib::RelinkableHandle<QuantLib::MarketElement> &, double, QuantLib::RelinkableHandle<QuantLib::TermStructure> &, QuantLib::RelinkableHandle<QuantLib::TermStructure> &, QuantLib::EuropeanExercise, QuantLib::RelinkableHandle<QuantLib::BlackVolTermStructure> &, QuantLib::Handle<QuantLib::PricingEngine> (&)(...))' ../../ql/Instruments/vanillaoption.hpp:51: candidates are: QuantLib::Instruments::VanillaOption::VanillaOption(QuantLib::Option::Type, const QuantLib::RelinkableHandle<QuantLib::MarketElement> &, double, const QuantLib::RelinkableHandle<QuantLib::TermStructure> &, const QuantLib::RelinkableHandle<QuantLib::TermStructure> &, const QuantLib::Date &, const QuantLib::RelinkableHandle<QuantLib::MarketElement> &, const QuantLib::Handle<QuantLib::PricingEngine> &, const string & = "", const string & = "") ../../ql/Instruments/vanillaoption.hpp:100: QuantLib::Instruments::VanillaOption::VanillaOption(const QuantLib::Instruments::VanillaOption &) *** Error code 1 make: Fatal error: Command failed for target `EuropeanOption.o' " I'm currenlty Sad advice: use gcc -lstdc++ instead of g++ Thank you for your help Xavier Luigi Ballabio <[hidden email]> To: [hidden email] Sent by: cc: [hidden email] [hidden email] Subject: Re: [Quantlib-users] exception handling on Unix eforge.net 21/05/2003 13:18 Xavier, would you mind trying this file? (See attached file: foo.cpp) ************************************************************************* Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de ses destinataires. Toute utilisation ou diffusion non autorisee est interdite. Tout message electronique est susceptible d'alteration. La Fimat et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie. ******** This message and any attachments (the "message") are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration. Neither Fimat nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified. ************************************************************************* foo.cpp (2K) Download Attachment |
Hi James,
thanks very much for this answer it sounds like a very good idea. Excuse me if the email was not very clear. My main problem is that I can't catch any quantlib exception, I always receive a core dump. For example this command: EuropeanOption opt(Option::Put,147.5,-1.0,0.0,0.03,0.0986,0.2); doesn't give me the expected quantlib error "Strike must be positive" but a core dump. Could you give me more clue, should I remove the ~Error() throw() {}? Thanks again Xavier "James Dalby" <[hidden email] To: <[hidden email]> om> cc: Subject: RE: [Quantlib-users] exception handling on Unix 20/06/2003 15:04 Xavier, I'm deeply suspicious of the 'throw()' in the destructor ~Error() This will be invoked at the end of the 'catch' block as the (copy contructed) exception 'e' is deleted. There is nothing to catch the 'throw()' and so the program will crash. I hope this is some use to you. I apologise if I've misunderstood your problem. Kind regards, James -----Original Message----- From: [hidden email] [mailto:[hidden email]]On Behalf Of [hidden email] Sent: Friday, June 20, 2003 1:41 PM To: [hidden email] Cc: [hidden email]; [hidden email] Subject: Re: [Quantlib-users] exception handling on Unix Hi Luigi, I'm still facing the same issue to handle QL exceptions on Unix, I tried to debug the program but I'd like to ask you some help. I tried to compile with the last version of GCC and last version of Quantlib and nothing works; still the same core dump. I tried to compile with other options like -lstdc++ or shared-libgcc but still the same core dump. I tried a main source code like: int main() { try { QL_REQUIRE(1 < 0.0,"exception"); } catch (std::exception& e) { std::cout<<"in exception"<<std::endl; std::cerr << e.what() << std::endl; return 1; } } and here it works, it gives me the "in exception exception". Now in debug mode I see that the program goes until \ql\errors.hpp at this level: class Error : public std::exception { public: explicit Error(const std::string& what = "") : message(what) {} ~Error() throw() {} and here it crashes (certainly outside of errors.hpp) It's now getting hard to debug and I 'd like to know if you have an idea on what I could do to follow in analysing the problem and solve it. Thanks for your help Xavier Xavier ABULKER To: Luigi Ballabio <[hidden email]> 21/05/2003 cc: [hidden email], 15:27 [hidden email] Subject: Re: [Quantlib-users] exception handling on Unix (Document link: Xavier ABULKER) Hi Luigi, this second example gives me the error: " ~/QuantLib-0.3.1/Examples/EuropeanOption> make source='EuropeanOption.cpp' object='EuropeanOption.o' libtool=no \ depfile='.deps/EuropeanOption.Po' tmpdepfile='.deps/EuropeanOption.TPo' \ depmode=gcc /bin/bash ../../config/depcomp \ g++ -DHAVE_CONFIG_H -I. -I. -I../../ql -I../.. -I../.. -c -o EuropeanOption.o `test -f 'EuropeanOption.cpp' || echo './' `EuropeanOption.cpp EuropeanOption.cpp: In function `int main()': EuropeanOption.cpp:29: parse error before `)' EuropeanOption.cpp:32: no matching function for call to `QuantLib::Instruments::VanillaOption::VanillaOption (QuantLib::Option::Type, QuantLib::RelinkableHandle<QuantLib::MarketElement> &, double, QuantLib::RelinkableHandle<QuantLib::TermStructure> &, QuantLib::RelinkableHandle<QuantLib::TermStructure> &, QuantLib::EuropeanExercise, QuantLib::RelinkableHandle<QuantLib::BlackVolTermStructure> &, QuantLib::Handle<QuantLib::PricingEngine> (&)(...))' ../../ql/Instruments/vanillaoption.hpp:51: candidates are: QuantLib::Instruments::VanillaOption::VanillaOption(QuantLib::Option::Type, const QuantLib::RelinkableHandle<QuantLib::MarketElement> &, double, const QuantLib::RelinkableHandle<QuantLib::TermStructure> &, const QuantLib::RelinkableHandle<QuantLib::TermStructure> &, const QuantLib::Date &, const QuantLib::RelinkableHandle<QuantLib::MarketElement> &, const QuantLib::Handle<QuantLib::PricingEngine> &, const string & = "", const string & = "") ../../ql/Instruments/vanillaoption.hpp:100: QuantLib::Instruments::VanillaOption::VanillaOption(const QuantLib::Instruments::VanillaOption &) *** Error code 1 make: Fatal error: Command failed for target `EuropeanOption.o' " I'm currenlty Sad advice: use gcc -lstdc++ instead of g++ Thank you for your help Xavier Luigi Ballabio <[hidden email]> To: [hidden email] Sent by: cc: [hidden email] [hidden email] Subject: Re: [Quantlib-users] exception handling on Unix eforge.net 21/05/2003 13:18 Xavier, would you mind trying this file? (See attached file: foo.cpp) ************************************************************************* Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de ses destinataires. Toute utilisation ou diffusion non autorisee est interdite. Tout message electronique est susceptible d'alteration. La Fimat et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie. ******** This message and any attachments (the "message") are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration. Neither Fimat nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified. ************************************************************************* ************************************************************************* Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de ses destinataires. Toute utilisation ou diffusion non autorisee est interdite. Tout message electronique est susceptible d'alteration. La Fimat et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie. ******** This message and any attachments (the "message") are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration. Neither Fimat nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified. ************************************************************************* |
>I'm deeply suspicious of the 'throw()' in the destructor ~Error() >This will be invoked at the end of the 'catch' block as the (copy >contructed) exception 'e' is deleted. There is nothing to catch the >'throw()' and so the program will crash. No---the throw () after ~Error() is not a statement, it's an exception specification. It declares that ~Error() throws nothing, i.e., that it does not throw. This said, it is certainly possible that something goes wrong. You can try deleting the destructor and see what happens, to begin with. Or you can try applying the patch I'm attaching. Let me know if anything works. Later, Luigi errors.patch (1K) Download Attachment |
In reply to this post by Xavier.Abulker
Hi Luigi, there's still the core dump. Maybe I did something wrong. Using DDD debugger this is what I see: |
At 01:30 PM 6/23/03 +0200, [hidden email] wrote:
>there's still the core dump. > >Using DDD debugger this is what I see: > >2) Go to explicit Error(const std::string& what = "") : >std::runtime_error(what) in errors.hpp and ends with > >Program received signal SIGABRT, Aborted. >0xfeb9c724 in _libc_kill () from /usr/lib/libc.so.1 Ouch. Can you try and put a print statement inside the Error constructor body to see if the base class completes initialization? Also, have you any idea about when this behavior appeared? After updating QuantLib? Or some other tool? (gcc and stuff) Later, Luigi |
In reply to this post by Xavier.Abulker
Hi Luigi
If I change class Error : public std::runtime_error { public: explicit Error(const std::string& what = "") : std::runtime_error(what) { } to class Error : public std::runtime_error { public: explicit Error(const std::string& what = "") : std::runtime_error(what) { std::cout<<"in Error"<<std::endl; } then I see the error message "In Error" and the core dumped. I think It has never worked correclty on Unix, I've always seen the core dump instead of the error message but now I'm trying to link QuantLib with Java via JNI and that's not possible if I can't access to exceptions. Thanks for the time you spent on this issue. Regards Xavier Luigi Ballabio <luigi.ballabio@fast To: [hidden email] webnet.it> cc: [hidden email] Subject: RE: [Quantlib-users] exception handling on Unix 23/06/2003 15:31 At 01:30 PM 6/23/03 +0200, [hidden email] wrote: >there's still the core dump. > >Using DDD debugger this is what I see: > >2) Go to explicit Error(const std::string& what = "") : >std::runtime_error(what) in errors.hpp and ends with > >Program received signal SIGABRT, Aborted. >0xfeb9c724 in _libc_kill () from /usr/lib/libc.so.1 Ouch. Can you try and put a print statement inside the Error constructor body to see if the base class completes initialization? Also, have you any idea about when this behavior appeared? After updating QuantLib? Or some other tool? (gcc and stuff) Later, Luigi ************************************************************************* Ce message et toutes les pieces jointes (ci-apres le "message") sont confidentiels et etablis a l'intention exclusive de ses destinataires. Toute utilisation ou diffusion non autorisee est interdite. Tout message electronique est susceptible d'alteration. La Fimat et ses filiales declinent toute responsabilite au titre de ce message s'il a ete altere, deforme ou falsifie. ******** This message and any attachments (the "message") are confidential and intended solely for the addressees. Any unauthorised use or dissemination is prohibited. E-mails are susceptible to alteration. Neither Fimat nor any of its subsidiaries or affiliates shall be liable for the message if altered, changed or falsified. ************************************************************************* |
Free forum by Nabble | Edit this page |