Hi all,
I've been scratching my head over this one for the last two hours, and I can't make any sense of it. My RQuantLib glue package for R has a few of the option pricers, as well as some of the implieds. Right now (i.e. with 0.3.7) I am getting a weird segfault when I do what is essentially a straight copy of the corresponding code in test-suite/europeanoption.cpp. In particular, the segfault only occurs if the second assignment in if (value != 0.0) { vol->setValue(volguess*1.5); // shift guess somehow implVol = option->impliedVolatility(value, tolerance, maxEvaluations); } is run, i.e. if the impliedVolatility() search is done. What is weirder still is that the code appears to return, give control back to the dynamically-loaded function loaded by R, and then segfaults when that outer R interface function terminates. Nothing has changed on the R side of things. On the other hand, running the QL code as a small C++ standalone works too. Now, both R and QL do 'things' with dynamic memory. Could there be a new corruption coming in somewhere? This error only showed up after I converted (belatedly) to the boost framework. And for what it is worth, the other examples (pricers for european, american, binary, barrier, ...) all work fine with boost. Likewise, the impliedVol code works if I comment out the call to option->impliedVolatility(...) Any ideas? Dirk -- Those are my principles, and if you don't like them... well, I have others. -- Groucho Marx |
On 2004.09.11 23:21, Dirk Eddelbuettel wrote:
> My RQuantLib glue package for R has a few of the option pricers, as > well as some of the implieds. Right now (i.e. with 0.3.7) I am > getting a weird segfault when I do what is essentially a straight > copy of the corresponding code in test-suite/europeanoption.cpp. Dirk, I apologize fo the delay. It's been a hard week... I confess I'm clueless on this. You're working on a Debian box, I guess... it shouldn't happen that R and QuantLib were build linking against different libc or something, isn't it? Later, Luigi |
From: Dirk Eddelbuettel <edd>
To: Luigi Ballabio <[hidden email]> Cc: Bcc: Subject: Re: [Quantlib-users] SegFault with with impliedVolatility Reply-To: In-Reply-To: <[hidden email]> Hi Luigi Thanks for looking at this. On Fri, Sep 17, 2004 at 02:22:21PM +0200, Luigi Ballabio wrote: > On 2004.09.11 23:21, Dirk Eddelbuettel wrote: > >My RQuantLib glue package for R has a few of the option pricers, as > >well as some of the implieds. Right now (i.e. with 0.3.7) I am > >getting a weird segfault when I do what is essentially a straight > >copy of the corresponding code in test-suite/europeanoption.cpp. > > Dirk, > I apologize fo the delay. It's been a hard week... > I confess I'm clueless on this. You're working on a Debian box, I > guess... it shouldn't happen that R and QuantLib were build linking > against different libc or something, isn't it? No, shouldn't. And they both had been rebuilt relatively close to each other: edd@chibud:~> ls -l /usr/lib/libQuantLib.so /usr/lib/R/bin/libR.so -rw-r--r-- 1 root root 1638320 Aug 31 22:09 /usr/lib/R/bin/libR.so lrwxrwxrwx 1 root root 20 Jul 29 20:08 /usr/lib/libQuantLib.so -> libQuantLib-0.3.7.so Below is 'ldd -v output', I see no smoking gun. Do you? Maybe I should try valgrind or something like that. Not sure how to set that up for both QL and R... Dirk chibud:~> ldd -v /usr/lib/libQuantLib.so /usr/lib/R/bin/libR.so /usr/lib/libQuantLib.so: libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x40409000) libm.so.6 => /lib/libm.so.6 (0x404c3000) libc.so.6 => /lib/libc.so.6 (0x404e5000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x40619000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000) Version information: /usr/lib/libQuantLib.so: libgcc_s.so.1 (GCC_3.0) => /lib/libgcc_s.so.1 libm.so.6 (GLIBC_2.0) => /lib/libm.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libstdc++.so.5 (CXXABI_1.2) => /usr/lib/libstdc++.so.5 libstdc++.so.5 (GLIBCPP_3.2) => /usr/lib/libstdc++.so.5 /usr/lib/libstdc++.so.5: libc.so.6 (GLIBC_2.2) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/libc.so.6 libgcc_s.so.1 (GCC_3.3) => /lib/libgcc_s.so.1 libgcc_s.so.1 (GCC_3.0) => /lib/libgcc_s.so.1 libgcc_s.so.1 (GLIBC_2.0) => /lib/libgcc_s.so.1 /lib/libm.so.6: ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2 libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /lib/libc.so.6: ld-linux.so.2 (GLIBC_2.1) => /lib/ld-linux.so.2 ld-linux.so.2 (GLIBC_2.0) => /lib/ld-linux.so.2 ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2 /lib/libgcc_s.so.1: libc.so.6 (GLIBC_2.2.4) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /usr/lib/R/bin/libR.so: libblas.so.3 => /usr/lib/atlas/libblas.so.3 (0x401d6000) libg2c.so.0 => /usr/lib/libg2c.so.0 (0x40517000) libm.so.6 => /lib/libm.so.6 (0x40536000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x40558000) libpcre.so.3 => /usr/lib/libpcre.so.3 (0x40561000) libbz2.so.1.0 => /usr/lib/libbz2.so.1.0 (0x40571000) libz.so.1 => /usr/lib/libz.so.1 (0x40581000) libreadline.so.4 => /lib/libreadline.so.4 (0x40593000) libdl.so.2 => /lib/libdl.so.2 (0x405c0000) libncurses.so.5 => /lib/libncurses.so.5 (0x405c3000) libc.so.6 => /lib/libc.so.6 (0x40602000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000) Version information: /usr/lib/R/bin/libR.so: libdl.so.2 (GLIBC_2.1) => /lib/libdl.so.2 libdl.so.2 (GLIBC_2.0) => /lib/libdl.so.2 libm.so.6 (GLIBC_2.0) => /lib/libm.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/libc.so.6 libc.so.6 (GLIBC_2.2) => /lib/libc.so.6 libc.so.6 (GLIBC_2.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /usr/lib/atlas/libblas.so.3: libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /usr/lib/libg2c.so.0: libm.so.6 (GLIBC_2.0) => /lib/libm.so.6 libc.so.6 (GLIBC_2.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.2) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /lib/libm.so.6: ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2 libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /lib/libgcc_s.so.1: libc.so.6 (GLIBC_2.2.4) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /usr/lib/libpcre.so.3: libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /usr/lib/libbz2.so.1.0: libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /usr/lib/libz.so.1: libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /lib/libreadline.so.4: libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /lib/libdl.so.2: libc.so.6 (GLIBC_2.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/libc.so.6 libc.so.6 (GLIBC_PRIVATE) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2 /lib/libncurses.so.5: libc.so.6 (GLIBC_2.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/libc.so.6 /lib/libc.so.6: ld-linux.so.2 (GLIBC_2.1) => /lib/ld-linux.so.2 ld-linux.so.2 (GLIBC_2.0) => /lib/ld-linux.so.2 ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2 -- Those are my principles, and if you don't like them... well, I have others. -- Groucho Marx |
Hi Dirk
if it can be of help I'm willing to compile your RQuantLib source code using Visual C++ and see if the same problem arise. Are you using impliedVolatility() with European or exotic options? Its usage with exotic options is uncovered in our test-suite and you might have found a genuine bug. ciao -- Nando |
Nando,
On Sun, Sep 19, 2004 at 09:55:02AM +0200, Ferdinando Ametrano wrote: > Hi Dirk > > if it can be of help I'm willing to compile your RQuantLib source code > using Visual C++ and see if the same problem arise. Thanks, though AFAIK it only works with the Msys/Mingw variety of gcc as it needs to link to R. > Are you using impliedVolatility() with European or exotic options? Its > usage with exotic options is uncovered in our test-suite and you might have > found a genuine bug. It blows up for American and European if and only if I call impliedVolatility() as in if (value != 0.0) { vol->setValue(volguess*1.5); // shift guess somehow implVol = option->impliedVolatility(value, tolerance, maxEvaluations); } If I assign implVol = 0.1234; or so it runs fine. The rest of the code is from the test-suite, plus what I need to communicate with R. Dirk -- Those are my principles, and if you don't like them... well, I have others. -- Groucho Marx |
Free forum by Nabble | Edit this page |