bugGNU Octave - Bugs: bug #39000, Can't override BLAS XERBLA handler...

 
 

bug #39000: Can't override BLAS XERBLA handler on Windows

Submitted by:  Clemens Buchacher <drizzd>
Submitted on:  Wed May 15 16:07:23 2013  
 
Category: LibrariesSeverity: 4 - Important
Priority: 7 - HighItem Group: Crash
Status: FixedAssigned to: None
Originator Name: Clemens BuchacherOpen/Closed: Closed
Release: devOperating System: Microsoft Windows

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Thu Oct 6 15:59:02 2016, comment #29:

I pushed this changeset:

http://hg.savannah.gnu.org/hgweb/octave/rev/5aa8f199e328

Closing this rerport as fixed. If more cases pop up, we need to fix them individually. I don't see any generally reliable way to replace xerbla with our own function.

John W. Eaton <jwe>
Project Administrator
Wed Oct 5 20:20:02 2016, comment #28:

At least for the reference BLAS and LAPACK, I think that the only way that xerbla can be called is if we call a BLAS or LAPACK function incorrectly. If we can avoid doing that, then we shouldn't even need to override the default version of XERBLA.

It is still nice to replace that function on systems where it is possible (and really, it should be possible on all systems) so that we can avoid causing Octave to exit if there is an accidentally incorrect call to a BLAS or LAPACK function.

John W. Eaton <jwe>
Project Administrator
Wed Oct 5 19:48:18 2016, comment #27:

Sorry, I meant:

Without this patch every one of the examples ends with a crash (on Windows).

Maybe there is a better solution, I do not know....

Avinoam Kalma <avinoam>
Project Member
Wed Oct 5 19:44:28 2016, comment #26:

@Avinoam:
Your answer is a bit ambiguous to me, sorry.

"... ends with a crash" - with or without the patch ?

In my case patch file #38631 fixed the issue AFAICS.

Philip Nienhuis <philipnienhuis>
Project Member
Tue Oct 4 21:06:19 2016, comment #25:

>> "does this patch really help the windows users?"


In Windows, every one of the examples ends with a crash.

Avinoam Kalma <avinoam>
Project Member
Tue Oct 4 21:00:04 2016, comment #24:

Windows seems to be more important, but for Linux there is no regression with file #38631

So does this patch really help the windows users and should this patch go in the 4.2 release? Then it should happen very soon.

Kai Torben Ohlhus <siko1056>
Project Member
Sun Oct 2 15:52:23 2016, comment #23:

That latest patch (file #38631) seems to work fine in a --enable-windows-64 cross build:

I'm no C++ style expert but it looks good enough to me.

Should the "[ inf 2345 ] / 5" case be included as a test to be able to detect regressions?

Philip Nienhuis <philipnienhuis>
Project Member
Fri Sep 30 16:17:39 2016, comment #22:

Please review the attached patch

(file #38631)

Avinoam Kalma <avinoam>
Project Member
Tue Aug 30 06:41:27 2016, comment #21:

@Avinoam: just nasty because I find it tedious to criticize coding style, if the patch itself is good ;-) sorry a bit off topic

Kai Torben Ohlhus <siko1056>
Project Member
Mon Aug 29 19:38:39 2016, comment #20:

@Kai: Thanks for your remarks (Why nasty?)

Actually, this patch does solve some other bug reports, like bug #46330, (test/bug-46330.tst can be tested on Windows too).

About the coding stile - I'll try to improve the patch. Thanks :-)

Avinoam Kalma <avinoam>
Project Member
Mon Aug 29 08:37:52 2016, comment #19:

I have tested the patch of comment #18 on Linux without problems. Calls like in comment #17 result in a nice warning, like Matlab does.

Before:

After:

But as said in comment #17, only one of many potential cases is fixed by this patch.

Another nasty remark is the code formatting. Please do not introduce multiple empty lines and lines with only white space characters. See http://wiki.octave.org/C%2B%2B_style_guide.

Kai Torben Ohlhus <siko1056>
Project Member
Mon Aug 29 04:23:39 2016, comment #18:

Another patch included. Please review.

This patch calculates the matrix norm, and if it is Inf or NaN,
the result is set to zero, rcon is also set to zero, and a singular matrix warning is shown. I have used
octave::warn_singular_matrix (), but maybe another warning should be used.

(file #38375)

Avinoam Kalma <avinoam>
Project Member
Tue Aug 23 09:51:49 2016, comment #17:

Checking the example

The error (and the crash after it) is produced in calling

(line 2130 in liboctave/array/dMatrix.cc).

A workaround can be something like:

Checking the matrix norm (like in http://hg.savannah.gnu.org/hgweb/octave/rev/bf5fbf347aaf), and avoiding calling dgelsd in case of problematic norn.
But this changeset does not set an error or warning, as it should.

Such modification should also apply to other *Matrix.cc files.

Avinoam Kalma <avinoam>
Project Member
Fri Jul 29 15:22:57 2016, comment #16:

Unfortunately, not all BLAS libraries make it easy to override the default error handler even though that was the original intent of having xerbla...

I suppose we could fix this for our mxe-octave builds for openblas and the reference blas. But that doesn't solve the problem generally. To do that requires cooperation from the people who are writing and packaging BLAS libraries.

Also, as I understand it, XERBLA should only be invoked when a BLAS or LAPACK routine is called incorrectly and we really shouldn't be making calls with invalid parameters.

For the example in comment 13, isn't that just a variation of bug #46330? But even though that bug is closed, I don't think it is really fixed yet. I'll comment there as well.

John W. Eaton <jwe>
Project Administrator
Thu Feb 5 01:25:19 2015, comment #15:

I just got a Windows VM set up, same segfault here.

Mike Miller <mtmiller>
Project Administrator
Thu Feb 5 01:16:43 2015, comment #14:

The simpler test case

produces the error you cited

The Windows OS then catches the error and says that the application tried to read memory at 0x010 (clearly a segfault) and then the program exits.

Re-titling the bug to reflect the real issue of being unable to override the XERBLA handler on Windows.

Rik <rik5>
Project Administrator
Wed Feb 4 15:27:08 2015, comment #13:

Yes, this particular test case looks solved.

However, you're not seeing the xerbla error message that's supposed to show up if this test case were still triggering the underlying problem.

I closed bug #36211 as a duplicate of this one. The simpler test case in that report still shows the xerbla message on Linux for me, what does

do for you on Windows? On Linux, it prints "On entry to DLASCL parameter number 4 had an illegal value" and then catches the error and returns to the Octave prompt. On Windows, last time I checked, this would cause Octave to abort, which is what this bug is really about.

Mike Miller <mtmiller>
Project Administrator
Wed Feb 4 04:15:30 2015, comment #12:

@Mike: I used a very recent tip (2/3/15) and I don't experience any problem with the test data. I used the NSIS installer route and tried both reference BLAS and OpenBLAS. I think whatever gremlin was there has been excised. If you're fine with that level of testing you can close the report.

Rik <rik5>
Project Administrator
Wed Feb 4 01:53:23 2015, comment #11:

@Mike: I have a Windows XP VM. I'll test tonight. Going through the MXE compile though is going to take 1-2 hours.

Rik <rik5>
Project Administrator
Fri Jan 30 16:06:00 2015, comment #10:

Is the BLAS/LAPACK error handler still not being correctly overridden in the current MXE build? I was able to reproduce this a year ago, but I don't have my WinXP VM at the moment to test a current build.

Mike Miller <mtmiller>
Project Administrator
Sat Jan 11 20:27:02 2014, comment #9:

I get the same error as the original report with an MXE build of 3.8.0 in a Windows XP VM.

Mike Miller <mtmiller>
Project Administrator
Sat May 18 08:25:07 2013, comment #8:

The system is a Core i5-2540M @ 2.60 GHz with Windows 7 64-bit.

I have changed MXE to build gcc 4.8.0 as a cross-compiler, which includes gfortran. So that may also make a difference in terms of floating point arithmetic.

Clemens Buchacher <drizzd>
Fri May 17 15:17:56 2013, comment #7:

I'm not able to reproduce the problem with the MXE build either.

I do see a message about the matrix being singular, but no error from lapack.

What hardware are you using? I'm running in a virtual box system with Windows 7 installed.

In any case, I guess we should fix the MXE build so that we can overrride XERBLA with our own version so that it doesn't exit.

John W. Eaton <jwe>
Project Administrator
Fri May 17 13:12:12 2013, comment #6:

I also cannot reproduce on Linux with octave 3.7.3+, lapack 3.4.2.

Clemens Buchacher <drizzd>
Fri May 17 13:01:00 2013, comment #5:

I did not modify the lapack version in my MXE build. The version is 3.4.2.

In SRC/dlasd8.f there is this code:

CALL DLASD4( K, J, DSIGMA, Z, WORK( IWK1 ), RHO, D( J ),
$ WORK( IWK2 ), INFO )
*

  • If the root finder fails, the computation is terminated.

*
IF( INFO.NE.0 ) THEN
CALL XERBLA( 'DLASD4', -INFO )
RETURN
END IF

And XERBLA seems to print the error message that I am getting. DLASD8 in turn gets called via functions such as zgelsd.

Clemens Buchacher <drizzd>
Wed May 15 22:17:23 2013, comment #4:

I'm unable to duplicate the problem. Are you using the reference version fo lapack that is included in the MXE-octave build, or replacing it with some other version?

The version of DLASD4 that is used by my MXE-octave build does not appear to do any argument checking. So I don't see where that message is coming from.

Also, Octave doesn't call DLASD4 directly, so if there is an invalid call, it seems that it would be a bug in LAPACK.

John W. Eaton <jwe>
Project Administrator
Wed May 15 16:47:01 2013, comment #3:

That's because you can't do it in Win32 (at least not in the way you do it under Linux/UNIX). The functions in the BLAS DLL will always resolve xerbla to the symbol present in the BLAS DLL (I believe this is done at link time, when the DLL is created).

Michael Goffioul <goffioul>
Project Member
Wed May 15 16:32:17 2013, comment #2:

This sounds like the same symptom as bug #38575. The xerbla error handler in liboctave is not overriding the xerbla error handler in the BLAS/LAPACK libraries.

Mike Miller <mtmiller>
Project Administrator
Wed May 15 16:09:52 2013, comment #1:

Just to be clear. This crashes Octave, closing the command line window or returning back the cmd shell.

Clemens Buchacher <drizzd>
Wed May 15 16:07:23 2013, original submission:

With my MXE build of the development branch I get this crash with the attached file.

% crashme.m
xy = load('xy.txt');
x = xy.x;
y = xy.y;
z = x\y;

> crashme

warning: matrix singular to machine precision, rcond = 1.57068e-020

    • On entry to DLASD4 parameter number -1 had an illegal value

Where:

> size(xy.x)

ans =

350 350

> size(xy.y)

ans =

350 1

Does not happen with the 3.6.4 mingw build from the wiki:

> crashme

warning: matrix singular to machine precision, rcond = 8.43218e-021

Clemens Buchacher <drizzd>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #38631:  bug39000_v2.diff added by avinoam (7kB - application/octet-stream)
file #38375:  bug39000.patch added by avinoam (2kB - application/octet-stream)
file #28088:  xy.dat.tar.gz added by drizzd (12kB - application/x-gzip)

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -unavailable- added by siko1056 (Posted a comment)
  • -unavailable- added by avinoam
  • -unavailable- added by avinoam (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by goffioul (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by drizzd (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 18 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu Oct 6 15:59:02 2016jweStatusPatch Submitted=>Fixed
      Open/ClosedOpen=>Closed
    Tue Oct 4 21:00:04 2016siko1056Priority5 - Normal=>7 - High
    Fri Sep 30 16:17:39 2016avinoamAttached File-=>Added bug39000_v2.diff, #38631
    Mon Aug 29 04:23:39 2016avinoamAttached File-=>Added bug39000.patch, #38375
      StatusConfirmed=>Patch Submitted
      Carbon-Copy-=>Added siko1056
    Sat Sep 12 21:54:22 2015mtmillerDependencies-=>bugs #45484 is dependent
    Tue Sep 1 15:25:35 2015rik5Dependencies-=>bugs #45849 is dependent
    Thu Feb 5 01:25:19 2015mtmillerSeverity3 - Normal=>4 - Important
    Thu Feb 5 01:16:43 2015rik5StatusFixed=>Confirmed
      Summarymldivide crashes with DLASD4 parameter error=>Can't override BLAS XERBLA handler on Windows
    Wed Feb 4 04:15:30 2015rik5StatusConfirmed=>Fixed
    Fri Jan 30 16:04:18 2015mtmillerDependencies-=>bugs #43610 is dependent
    Sat Jan 11 20:31:42 2014mtmillerDependencies-=>bugs #36211 is dependent
    Sat Jan 11 20:27:02 2014mtmillerCategoryNone=>Libraries
      StatusNone=>Confirmed
    Wed May 15 16:07:23 2013drizzdAttached File-=>Added xy.dat.tar.gz, #28088

    Back to the top


    Powered by Savane 3.1-cleanup