forum.alglib.net

ALGLIB forum
It is currently Thu Aug 13, 2020 5:35 am

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: AlgLib crashing with release build
PostPosted: Mon Jan 13, 2020 4:58 pm 
Offline

Joined: Mon Jan 13, 2020 4:51 pm
Posts: 5
Hello,

I have an application working with Alglib, and most of the time it works great. Occasionally my application crashes, but only when running the release build (not debug build). It is intermittent, the same inputs (data, fitting function, and initial guess) don't always result in a crash so it is difficult to duplicate. I did generate an assembly listing of the release build and found the offset of the crash which appears below. I have try{}catch() around my calls to alglib::lsfitfit(), so I don't think it is throwing an exception. Does anyone understand how to follow this assembly listing, or have a suggestion on how to debug this intermittent crash?

I am doing fairly simple nonlinear fitting with small and simple data sets.

Excerpt of assembly listing (crash was at offset 41fc93:

<__ZN6alglib16kdtreetsqueryrnnERKNS_6kdtreeERKNS_19kdtreerequestbufferERKNS_13real_1d_arrayEdbNS_7xparamsE+0x90>
41f964: c7 04 24 18 00 00 00 movl $0x18,(%esp)
41f96b: e8 80 9d 1b 00 call 5d96f0 <___cxa_allocate_exception>
41f970: 89 c3 mov %eax,%ebx
41f972: 8b 45 dc mov -0x24(%ebp),%eax
41f975: 89 d9 mov %ebx,%ecx
41f977: 89 04 24 mov %eax,(%esp)
41f97a: e8 31 1b 01 00 call 4314b0 <__ZN6alglib8ap_errorC1EPKc>
41f97f: 83 ec 04 sub $0x4,%esp
41f982: c7 44 24 08 f0 71 5e movl $0x5e71f0,0x8(%esp)
41f989: 00
41f98a: c7 44 24 04 d4 86 64 movl $0x6486d4,0x4(%esp)
41f991: 00
41f992: 89 1c 24 mov %ebx,(%esp)
41f995: e8 1e 9d 1b 00 call 5d96b8 <___cxa_throw>
41f99a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi
41f9a0: 8d 85 60 ff ff ff lea -0xa0(%ebp),%eax
41f9a6: 8d 5d a0 lea -0x60(%ebp),%ebx
41f9a9: 89 44 24 04 mov %eax,0x4(%esp)
41f9ad: 89 1c 24 mov %ebx,(%esp)
41f9b0: e8 ab bd 00 00 call 42b760 <__ZN11alglib_impl23ae_state_set_break_jumpEPNS_8ae_stateEPA16_i>
41f9b5: 8b 85 50 ff ff ff mov -0xb0(%ebp),%eax
41f9bb: 0b 85 54 ff ff ff or -0xac(%ebp),%eax
41f9c1: 74 1c je 41f9df <__ZN6alglib16kdtreetsqueryrnnERKNS_6kdtreeERKNS_19kdtreerequestbufferERKNS_13real_1d_arrayEdbNS_7xparamsE+0xcf>
41f9c3: 8b 85 54 ff ff ff mov -0xac(%ebp),%eax


Top
 Profile  
 
 Post subject: Re: AlgLib crashing with release build
PostPosted: Mon Jan 13, 2020 5:11 pm 
Offline

Joined: Mon Jan 13, 2020 4:51 pm
Posts: 5
Actually, it does seem that it is trying to throw an exception, but I'm not catching it. "terminate called after throwing an instance of 'alglib::ap_error'" Any indication what causes this kind of error? Thanks,


Top
 Profile  
 
 Post subject: Re: AlgLib crashing with release build
PostPosted: Mon Jan 13, 2020 5:15 pm 
Offline

Joined: Mon Jan 13, 2020 4:51 pm
Posts: 5
Ahh (apparently I'm rubby ducky debugging) it isn't the alglib::lsfitfit() that is resulting in an exception, it is "lsfitcreate" that is throwing an exception. Any idea why lsfitcreate would throw an exception?


Top
 Profile  
 
 Post subject: Re: AlgLib crashing with release build
PostPosted: Mon Jan 13, 2020 5:20 pm 
Offline

Joined: Mon Jan 13, 2020 4:51 pm
Posts: 5
Ok, here is the error text from that exception: "LSFitCreateF: X contains infinite or NaN values!"

So that explains my error. Now I just need to check and eliminate those.


Top
 Profile  
 
 Post subject: Re: AlgLib crashing with release build
PostPosted: Mon Jan 13, 2020 5:41 pm 
Offline

Joined: Mon Jan 13, 2020 4:51 pm
Posts: 5
Well, for what it is worth, I figured out my issue, posting here in case it helps someone else. I was initializing my x variable this way:

real_2d_array x;
x.setlength(xF.length(),2);

But only setting data into column 0 (row 0?).

for (int i = 0; i < xF.length(); i++)
{
x[i][0] = xF[i];
y[i] = yF[i];
}

Apparently the other uninitialized column (row?) x[i][1] could randomly have NaNs or infinities. I changed my initialization statement to:

real_2d_array x;
x.setlength(xF.length(),1);

and I haven't been able to get another crash. It seems to be fixed (so far).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group