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

 
 

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

Submitted by:  None
Submitted on:  Fri 03 Jun 2016 06:30:00 AM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Segfault, Bus Error, etc.
Status: FixedAssigned to: None
Originator Name: Tom PistorOriginator Email: -unavailable-
Open/Closed: ClosedRelease: dev
Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

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>
Project Administrator
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>
Project 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>
Project 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 File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 04 Jun 2016 04:04:00 AM UTCmtmillerStatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Fri 03 Jun 2016 08:49:24 AM UTCphilipnienhuisStatusNone=>Confirmed
      Release4.0.2=>dev
      Operating SystemGNU/Linux=>Any

    Back to the top


    Powered by Savane 3.1-cleanup1