Re: Excel 2007 crashes on exit after QLXL call that returns an object

Posted by Dave Blob on
URL: http://quantlib.414.s1.nabble.com/Excel-2007-crashes-on-exit-after-QLXL-call-that-returns-an-object-tp5666p5667.html

I think I've found the problem-

It looks like when CallingRanges are destroyed, they call Excel(xlfSetName, ...).  However I see CallingRanges being destroyed after xlAutoClose, which calls Excel(xlfFree).  I think this causes the seg faults.

To fix the problem I added ReposityXL::clear() - which merely calls calllingNames_.clear().  I call ObjectHandler::ReposityXL::instance().clear() before Excel(xlfFree) - and the access violations seem to have gone away.  I can submit a patch if you think this it is helpful (right now I have a patch for a heavily stripped down version that I used to isolate the bug).

Best,
Dave

Dave Blob wrote
Hi -

I'm trying to upgrade our copy of QuantLib from 0.8.0 to 1.1.0.  

Both the debug and release versions that I've built crash on exit if I've made a QuantLibXL call which returns an object (for Example, qlSimpleQuote(,5,5).  If I don't call any QuantLib functions, or call functions that only return strings - for example qlxlVersion - excel exits normally.

To make sure this is not something specific to my environment - I built a clean windows 7 (x64) machine which only has a fresh copy of office 2007 and visual studio 2005, all fully patched.  Both the 1.1 build and the current svn build still crash on exit.   On my previous machine I tried VS 2008 which also failed.  I've tried boost 1.42 and boost 1.47.

When I run excel from the VS2005  debugger, I get an error like:

        Unhandled exception at 0x10abec61 in excel.exe: 0xC0000005:
        Access violation reading location 0x10abec61.

The stack trace does not show any QuantLib calls:

...

I noticed a thread like this a few years ago and never saw any resolution to it - is it a known bug?  Any suggestions on how I might proceed - are other version of visual studio or boost known to work better?

Thanks,
Dave