bugGNU Octave - Bugs: bug #48107, Seg fault on passing int32 as...

 
 

bug #48107: Seg fault on passing int32 as argument to javaMethod method

Submitter:  None
Submitted:  Fri 03 Jun 2016 06:30:00 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  Tom Pistor Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 04 Jun 2016 04:04:00 AM UTC, comment #5: 

I fixed this on the stable branch and merged it to default with these changesets:

http://hg.savannah.gnu.org/hgweb/octave/rev/e56ba70108d3
http://hg.savannah.gnu.org/hgweb/octave/rev/49d999dc443f

Thanks for reporting and identifying the problem lines. I added tests for these conversions and discovered a similar typo in the 64-bit integer conversion logic also, both should be working now.

Mike Miller <mtmiller>
Group Member
Fri 03 Jun 2016 09:45:05 PM UTC, comment #4: 

Thanks for the guidance.  Found bug:

In ov-java.cc

should be "java/lang/Integer", not "java/lang/Int"

two lines need to change:

      else IF_UNBOX_PRIMITIVE_SCALAR(int32,  int32_t,  int32_scalar,  "java/lang/Integer", "(I)V")
      else IF_UNBOX_PRIMITIVE_SCALAR(uint32, uint32_t, uint32_scalar, "java/lang/Integer", "(I)V")


Can somebody commit the fix?

Anonymous
Fri 03 Jun 2016 04:18:59 PM UTC, comment #3: 

isNaN just as example
Yeah that's what I figured :-)

Anyway the code to check is in libinterp/octave-value/ov-java.cc and/or libinterp/octave-value/ov-java.h
Somewhere in there the boxing/unboxing functions reside.

Philip Nienhuis <philipnienhuis>
Group Member
Fri 03 Jun 2016 01:39:19 PM UTC, comment #2: 

Used isNaN just as example.  I found the bug when calling my own Java method.  Seems javaMethod crashes any time int32 is passed as argument to the Java method when the Java method was expecting a double.

Anonymous
Fri 03 Jun 2016 08:49:24 AM UTC, comment #1: 

Confirmed on Win7 with w64 Octave-4.1.0+ (dev version built with --enable-windows-64).

One may wonder what use there is for checking for NaN values for integers through Java, but Octave shouldn't crash.

Some more investigation:
- crashes with int32 and uint32 input values
- does not crash with int16 and uint16 (returns 0 for any value, as expected for the isNaN method)
- has no corresponding methods for int8 and uint8 ("NoSuchMethodException")

OS -> Any
Release -> Dev

Philip Nienhuis <philipnienhuis>
Group Member
Fri 03 Jun 2016 06:30:00 AM UTC, original submission:  


>> a=1

a =  1

>> javaMethod('isNaN','java.lang.Double',a);
>> b=int32(a)

b = 1

>> javaMethod('isNaN','java.lang.Double',b);

panic: Segmentation fault -- stopping myself...
attempting to save variables to 'octave-workspace'...
save to 'octave-workspace' complete
Segmentation fault

This was not crashing prior to 4.0.0 octave release.  (used the java_invoke method)

Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by None (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-06-04 mtmiller StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2016-06-03 philipnienhuis StatusNone Confirmed
        Release4.0.2 dev
        Operating SystemGNU/Linux Any

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code