|
From: Ruilong Xu <xur...@ho...> - 2021-09-26 03:39:22
|
Hi, Thank you. As your suggestion, I create SafeFixedLocalVolSurface, and it works well in testHestonFokkerPlanckFwdEquationLogLVLeverage. But when SafeFixedLocalVolSurface is returned by function getFixedLocalVolFromHeston, it results double deletion still. You can find all codes here: https://github.com/xuruilong100/QuantLibPythonExamples/blob/main/SWIGpy/ql/termstructures/volatilitytermstructures/localvol/all.i (https://link.getmailspring.com/link/27F...@ge.../0?redirect=https%3A%2F%2Fgithub.com%2Fxuruilong100%2FQuantLibPythonExamples%2Fblob%2Fmain%2FSWIGpy%2Fql%2Ftermstructures%2Fvolatilitytermstructures%2Flocalvol%2Fall.i&recipient=cXVhbnRsaWItdXNlcnNAbGlzdHMuc291cmNlZm9yZ2UubmV0) https://github.com/xuruilong100/QuantLibPythonExamples/blob/main/testsuite/hestonslvmodel.py (https://link.getmailspring.com/link/27F...@ge.../1?redirect=https%3A%2F%2Fgithub.com%2Fxuruilong100%2FQuantLibPythonExamples%2Fblob%2Fmain%2Ftestsuite%2Fhestonslvmodel.py&recipient=cXVhbnRsaWItdXNlcnNAbGlzdHMuc291cmNlZm9yZ2UubmV0) Thanks again, Ruilong On Sep 22 2021, at 4:03 pm, Luigi Ballabio <lui...@gm...> wrote: > When you say > > ext::shared_ptr<Matrix> ptr(&localVolMatrix); > > in the wrapper, you're taking the address of an object with its own lifetime and give it to a shared_ptr that will try to delete it. This results in double deletion. You need to make a copy instead, as in > > ext::shared_ptr<Matrix> ptr(new Matrix(localVolMatrix)); > > Hope this helps, > Luigi > > > > > On Mon, Sep 20, 2021 at 11:04 AM Ruilong Xu <xur...@ho... (mailto:xur...@ho...)> wrote: > > Hi, > > > > I am reimplementing hestonslvmodel.cpp by Python. > > SafeFdmMesherIntegral works well. > > But SafeFixedLocalVolSurface may cause error in testAMoustacheGraph, the following is what I get: > > double free or corruption (top) > > Backend terminated or disconnected.Fatal Python error: Aborted > > > > > > > > On Sep 20 2021, at 4:03 pm, Luigi Ballabio <lui...@gm... (mailto:lui...@gm...)> wrote: > > > Hello, > > > shared_ptr should be supported correctly. How are you trying to wrap them? > > > > > > Luigi > > > > > > > > > On Fri, Sep 17, 2021 at 4:05 PM Ruilong Xu <xur...@ho... (mailto:xur...@ho...)> wrote: > > > > Hi, all > > > > > > > > Some members of FdmMesherIntegral and FixedLocalVolSurface are shared_ptr, it means that Python GC will cause error in sometimes. > > > > Is there an easy and safe way to make Python wrappers of them by SWIG? > > > > Best Regards, > > > > Ruilong > > > > > > > > _______________________________________________ > > > > QuantLib-users mailing list > > > > Qua...@li... (mailto:Qua...@li...) > > > > https://lists.sourceforge.net/lists/listinfo/quantlib-usersdouble free or corruption (top) (https://lists.sourceforge.net/lists/listinfo/quantlib-users) > > > > > > > > Backend terminated or disconnected.Fatal Python error: Aborted (https://lists.sourceforge.net/lists/listinfo/quantlib-users) > > _______________________________________________ > > QuantLib-users mailing list > > Qua...@li... (mailto:Qua...@li...) > > https://lists.sourceforge.net/lists/listinfo/quantlib-users > > |