bugGNU Octave - Bugs: bug #49057, oct-parse.in.yy unit test of evalc...

 
 

bug #49057: oct-parse.in.yy unit test of evalc crashes with MALLOC_PERTURB_ set

Submitter:  Dmitry <rdmitry>
Submitted:  Sun 11 Sep 2016 11:31:48 AM UTC
   
 
Category:  Test Suite Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.2.0-rc1 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 16 Sep 2016 04:52:56 PM UTC, comment #13: 

Thanks for testing and pushing this fix :)

Mike Miller <mtmiller>
Group Member
Fri 16 Sep 2016 04:23:37 PM UTC, comment #12: 

Thanks for testing.  I added a commit message and pushed the change under Mike's name.  Fixed, closing report.

Rik <rik5>
Group administrator
Fri 16 Sep 2016 04:05:19 PM UTC, comment #11: 

After applying patch from file #38510, the tests pass without crash.

Guillaume <gyom>
Fri 16 Sep 2016 02:59:47 PM UTC, comment #10: 

Can someone who can reproduce the problem test Mike's latest patch from 9/14?

Rik <rik5>
Group administrator
Wed 14 Sep 2016 04:57:19 PM UTC, comment #9: 

Attached patch seems to work for me and produces the same results. It's slightly more code than the original, but looks more straightforward and doesn't need the try-catch with duplicated cleanup or saving state and rethrowing.

(file #38510)

Mike Miller <mtmiller>
Group Member
Tue 13 Sep 2016 12:20:49 PM UTC, comment #8: 

Mike:  Yes, using an unwind_protect object is probably better.

John W. Eaton <jwe>
Group administrator
Tue 13 Sep 2016 09:29:33 AM UTC, comment #7: 

Both Mike and jwe's patches fix the crash on openSUSE.

Guillaume <gyom>
Tue 13 Sep 2016 06:16:31 AM UTC, comment #6: 

Yes that's probably fine also.

I don't think there's anything particularly wrong about copying an exception object and throwing a copy, it's just an object like any other.

Yet another cleaner way to do this might be to use unwind_protect to restore the state of the stdout and stderr streams after completion. That should work whether an exception is thrown or not, and no need to even catch and rethrow I think.

Mike Miller <mtmiller>
Group Member
Mon 12 Sep 2016 10:40:50 PM UTC, comment #5: 

Mike:  Is it OK to copy the exception and throw the copy?

If not, then what about the following patch?  I know it duplicates some code, but it avoids copying the exception.



(file #38491)

John W. Eaton <jwe>
Group administrator
Mon 12 Sep 2016 09:13:17 PM UTC, comment #4: 

Attaching a second patch which does this with a flag and a stack-allocated copy of the caught exception, which I think is the better way to do this.

Dmitry can you test whether this patch solves the error on your openSUSE testing?

(file #38488)

Mike Miller <mtmiller>
Group Member
Mon 12 Sep 2016 09:01:36 PM UTC, comment #3: 

The attached patch fixes the crash for me. I believe the code in evalc is indeed wrong. This patch introduces a leak, but I'm not sure what would be the proper way to clean up an exception object that is allocated on the heap and then thrown to be caught or not caught later.

I guess we could use a boolean flag instead of a pointer to an exception object that may or may not point to a valid exception.

(file #38487)

Mike Miller <mtmiller>
Group Member
Mon 12 Sep 2016 05:59:29 PM UTC, comment #2: 

The rest of the test suite runs to completion if I delete libinterp/parse-tree/oct-parse.in.yy-tst.

The crash seems to be coming from tests involving eval or evalc, for example:


$ MALLOC_PERTURB_=1 ./run-octave -cli --eval "evalc (\"error ()\");"
error: Invalid call to error.  Correct usage is:

 -- error (TEMPLATE, ...)
 -- error (ID, TEMPLATE, ...)

Additional help for built-in functions and operators is
available in the online version of the manual.  Use the command
'doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at http://www.octave.org and via the help@octave.org
mailing list.
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
panic: Aborted -- stopping myself...
attempting to save variables to 'octave-workspace'...
save to 'octave-workspace' complete
Aborted


Mike Miller <mtmiller>
Group Member
Mon 12 Sep 2016 05:00:06 AM UTC, comment #1: 

Confirmed here on Debian, the following is enough to trigger the crash for me:


MALLOC_PERTURB_=1 ./run-octave --eval "test libinterp/parse-tree/lex.ll-tst; test libinterp/parse-tree/oct-parse.in.yy-tst"
PASSES 7 out of 7 tests
terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::_M_create
panic: Aborted -- stopping myself...
octave exited with signal 6


The lex.ll test cases must be run first, running tests in oct-parse.in.yy alone does not cause a crash.

Mike Miller <mtmiller>
Group Member
Sun 11 Sep 2016 11:31:48 AM UTC, original submission:  

Octave 4.2.0-rc1 crashes at post build tests for all openSUSE versions:


[ 1845s]   libinterp/parse-tree/oct-parse.in.yy-tst ....................terminate called after throwing an instance of 'std::length_error'
[ 1845s]   what():  basic_string::_M_create
[ 1845s] panic: Aborted -- stopping myself...


This situation is caused by strong build environment settings:


setenv MALLOC_CHECK_ 3
setenv MALLOC_PERTURB_ 69


Dmitry <rdmitry>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #38510:  evalc3.diff added by mtmiller (2KiB - text/x-diff)
file #38491:  diffs.txt added by jwe (2KiB - text/plain)
file #38488:  evalc2.diff added by mtmiller (1KiB - text/x-diff)
file #38487:  evalc.diff added by mtmiller (499B - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by gyom (Posted a comment)
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by rdmitry (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-09-16 rik5 Open/ClosedOpen Closed
    2016-09-16 rik5 StatusPatch Submitted Fixed
    2016-09-14 mtmiller Attached File- Added evalc3.diff, #38510
    2016-09-12 jwe Attached File- Added diffs.txt, #38491
    2016-09-12 mtmiller Attached File- Added evalc2.diff, #38488
        StatusConfirmed Patch Submitted
    2016-09-12 mtmiller Attached File- Added evalc.diff, #38487
    2016-09-12 mtmiller Summaryoct-parse.in.yy unit test crashes with MALLOC_PERTURB_ set oct-parse.in.yy unit test of evalc crashes with MALLOC_PERTURB_ set
    2016-09-12 mtmiller Summaryoct-parse test crash oct-parse.in.yy unit test crashes with MALLOC_PERTURB_ set
    2016-09-12 mtmiller StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code