Hello Quantlib,
Excuse me if this question is too basic but I'm trying to understand how to handle Quantlib exceptions on Unix. I haven't changed any option to compile quantlib with gcc and when an exception is returned I have "core dump" instead of a beautiful error message. I'm sure this is an option to change with gcc compiler but I can't find which one. Thank you for your help. Xavier ************************************************************************* 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. ************************************************************************* |
At 09:45 AM 5/21/03 +0200, [hidden email] wrote:
>Excuse me if this question is too basic but I'm trying to understand how to >handle Quantlib exceptions on Unix. >I haven't changed any option to compile quantlib with gcc and when an >exception is returned I have "core dump" instead of a beautiful error >message. Xavier, I'm not sure I understand. What is it exactly that you're doing? Are you linking the library to some application? And does the application properly handle exceptions? I mean, if you just write: int main() { throw Error("Boo!"); return 0; } the program will just abort---you'll have to write: int main() { try { throw Error("Boo!"); return 0; } catch (std::exception& e) { std::cerr << e.what() << std::endl; return 1; } catch (...) { std::cerr << "unknown error" << std::endl; return 2; } } after which the program will tell you what was the exception. Also, I'm not sure that even the above will work if some special kind of errors are raised (such as division by zero). In that case, you'll have to find out when that happens and add a check before the division... Was this what you were asking, or am I off the mark? Later, Luigi |
In reply to this post by Xavier.Abulker
Hi Luigi,
I'm using the EuropeanOption.cpp example to deduce the implied volatility of options. There's the try-catch in the source code as you explained me. Now everything goes fine except when it is impossible to find a solution. the Brent algorithm should give me an exception like:"Exception happend for matrix point: root not bracketed: f[0.0001000000,4.0000000000] -> [0.63761133978130147000,6.27375654274655490000]" (I see that on NT) but on Unix I only see a core dump. I'm wondering if it's not a bug with gcc with the option -O2 or -O3, I found on internet that people reported the same problem with gcc (until 3.1) on Unix or Linux using this option to compile. Xavier Luigi Ballabio <luigi.ballabio@fast To: [hidden email], [hidden email] webnet.it> cc: Subject: Re: [Quantlib-users] exception handling on Unix 21/05/2003 10:34 At 09:45 AM 5/21/03 +0200, [hidden email] wrote: >Excuse me if this question is too basic but I'm trying to understand how to >handle Quantlib exceptions on Unix. >I haven't changed any option to compile quantlib with gcc and when an >exception is returned I have "core dump" instead of a beautiful error >message. Xavier, I'm not sure I understand. What is it exactly that you're doing? Are you linking the library to some application? And does the application properly handle exceptions? I mean, if you just write: int main() { throw Error("Boo!"); return 0; } the program will just abort---you'll have to write: int main() { try { throw Error("Boo!"); return 0; } catch (std::exception& e) { std::cerr << e.what() << std::endl; return 1; } catch (...) { std::cerr << "unknown error" << std::endl; return 2; } } after which the program will tell you what was the exception. Also, I'm not sure that even the above will work if some special kind of errors are raised (such as division by zero). In that case, you'll have to find out when that happens and add a check before the division... Was this what you were asking, or am I off the mark? 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. ************************************************************************* |
Hi Xavier,
optimizations sometimes result in buggy code (that is why they are disabled by default). Using higher -O levels, the compiler gets more and more agressive with it assumptions on what can be "optimized". Do you have the same errors without optimization? Have you tried to run the test-suite with different optimization levels? Jens. -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of [hidden email] Sent: Wednesday, May 21, 2003 10:49 AM To: Luigi Ballabio Cc: [hidden email] Subject: Re: [Quantlib-users] exception handling on Unix Hi Luigi, I'm using the EuropeanOption.cpp example to deduce the implied volatility of options. There's the try-catch in the source code as you explained me. Now everything goes fine except when it is impossible to find a solution. the Brent algorithm should give me an exception like:"Exception happend for matrix point: root not bracketed: f[0.0001000000,4.0000000000] -> [0.63761133978130147000,6.27375654274655490000]" (I see that on NT) but on Unix I only see a core dump. I'm wondering if it's not a bug with gcc with the option -O2 or -O3, I found on internet that people reported the same problem with gcc (until 3.1) on Unix or Linux using this option to compile. Xavier Luigi Ballabio <luigi.ballabio@fast To: [hidden email], [hidden email] webnet.it> cc: Subject: Re: [Quantlib-users] exception handling on Unix 21/05/2003 10:34 At 09:45 AM 5/21/03 +0200, [hidden email] wrote: >Excuse me if this question is too basic but I'm trying to understand >how to >handle Quantlib exceptions on Unix. >I haven't changed any option to compile quantlib with gcc and when an >exception is returned I have "core dump" instead of a beautiful error >message. Xavier, I'm not sure I understand. What is it exactly that you're doing? Are you linking the library to some application? And does the application properly handle exceptions? I mean, if you just write: int main() { throw Error("Boo!"); return 0; } the program will just abort---you'll have to write: int main() { try { throw Error("Boo!"); return 0; } catch (std::exception& e) { std::cerr << e.what() << std::endl; return 1; } catch (...) { std::cerr << "unknown error" << std::endl; return 2; } } after which the program will tell you what was the exception. Also, I'm not sure that even the above will work if some special kind of errors are raised (such as division by zero). In that case, you'll have to find out when that happens and add a check before the division... Was this what you were asking, or am I off the mark? 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. ************************************************************************* ------------------------------------------------------- This SF.net email is sponsored by: ObjectStore. If flattening out C++ or Java code to make your application fit in a relational database is painful, don't do it! Check out ObjectStore. Now part of Progress Software. http://www.objectstore.net/sourceforge _______________________________________________ Quantlib-users mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-users |
In reply to this post by Xavier.Abulker
At 10:49 AM 5/21/03 +0200, [hidden email] wrote:
>I'm using the EuropeanOption.cpp example to deduce the implied volatility >of options. >There's the try-catch in the source code as you explained me. >Now everything goes fine except when it is impossible to find a solution. >the Brent algorithm should give me an exception like:"Exception happend for >matrix point: root not bracketed: f[0.0001000000,4.0000000000] -> >[0.63761133978130147000,6.27375654274655490000]" (I see that on NT) but on >Unix I only see a core dump. Xavier, can you send me the inputs you're using? Also, what kind of option are you analyzing? And if it is as European, are you using the old-style or the new-style option? Later, Luigi |
In reply to this post by Xavier.Abulker
Hi Luigi,
this is a European Put Option price = 0.01; maturity =0.0986; underlyingPrice =147.5; strike =1; then I define EuropeanOption Europeanoptioniv(Option::Put,underlyingPrice,strike,dividend,zero_rate,maturity,implvol); and return the implied vol in database std::cout<<"OPTION IMPLIED VOL= " <<Europeanoptioniv.impliedVolatility(price) I know that the strike is crazy but unfortunately this option exists on the market, a price is given everyday by the market place and my clients have it in in their portfolio! Luigi Ballabio <luigi.ballabio@fast To: [hidden email] webnet.it> cc: [hidden email] Subject: Re: [Quantlib-users] exception handling on Unix 21/05/2003 11:12 At 10:49 AM 5/21/03 +0200, [hidden email] wrote: >I'm using the EuropeanOption.cpp example to deduce the implied volatility >of options. >There's the try-catch in the source code as you explained me. >Now everything goes fine except when it is impossible to find a solution. >the Brent algorithm should give me an exception like:"Exception happend for >matrix point: root not bracketed: f[0.0001000000,4.0000000000] -> >[0.63761133978130147000,6.27375654274655490000]" (I see that on NT) but on >Unix I only see a core dump. Xavier, can you send me the inputs you're using? Also, what kind of option are you analyzing? And if it is as European, are you using the old-style or the new-style option? 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. ************************************************************************* |
Xavier, the attached file works as expected for me by just doing: ballabl:~$ g++ foo.cpp -lQuantLib ballabl:~$ ./a.out solver1d.cpp:125: root not bracketed: f[0.0001000000,4.0000000000] -> [-0.01000000000000000021,-0.00989983370038110579] ballabl:~$ Can you try and see what happens for you? However, note that I'm using the version of the library currently in cvs, not 0.3.1. Also, I'm using g++ 3.2.3. Good luck, Luigi foo.cpp (575 bytes) Download Attachment |
In reply to this post by Xavier.Abulker
Hi Luigi, thanks for this file, just compiling like that it gives the same error "core dumped". Now I'm going to remove all the -O3 in the compilation options and then test again. bye 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 11:34 Xavier, the attached file works as expected for me by just doing: ballabl:~$ g++ foo.cpp -lQuantLib ballabl:~$ ./a.out solver1d.cpp:125: root not bracketed: f[0.0001000000,4.0000000000] -> [-0.01000000000000000021,-0.00989983370038110579] ballabl:~$ Can you try and see what happens for you? However, note that I'm using the version of the library currently in cvs, not 0.3.1. Also, I'm using g++ 3.2.3. Good luck, Luigi(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 (576 bytes) Download Attachment |
In reply to this post by 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 |
At 03:27 PM 5/21/03 +0200, [hidden email] wrote:
>Hi Luigi, >this second example gives me the error: >... Hmm, probably a version mismatch---I'm using the latest cvs, not 0.3.1... oh well, never mind... >I'm currenlty Sad advice: use gcc -lstdc++ instead of g++ Does it work? Bye, Luigi |
Free forum by Nabble | Edit this page |