bugGNU Octave - Bugs: bug #41163, Octave crashes when compiled with...

 
 

bug #41163: Octave crashes when compiled with 64 bit indexing and jit enabled

Submitted by:  Lasse Schuirmann <sils1297>
Submitted on:  Thu 09 Jan 2014 12:09:20 PM UTC  
 
Category:  Configuration and Build System Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Build Failure
Status:  Fixed Assigned to:  None
Originator Name:  Lasse Schuirmann Open/Closed:  Closed
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

Tue 14 Jan 2014 07:28:05 PM UTC, comment #4: 

No worries about the patch.  I simplified both instances and checked in a patch (http://hg.savannah.gnu.org/hgweb/octave/rev/e243b705a726), giving you credit since you saw this first.

Rik <rik5>
Project Administrator
Tue 14 Jan 2014 07:10:48 PM UTC, comment #3: 

There is no reason besides me trying to mimic the code style in this document. The same case is handled this way in line 1613 so I just copied it.

So I can upload a simplified patch tomorrow or so.

Lasse Schuirmann <sils1297>
Tue 14 Jan 2014 06:52:39 PM UTC, comment #2: 

The attached patch is written as

diff -r c95b23fca6fd -r 851ecd3be950 libinterp/corefcn/jit-typeinfo.cc
--- a/libinterp/corefcn/jit-typeinfo.cc        Wed Jan 08 14:42:56 2014 +0100
+++ b/libinterp/corefcn/jit-typeinfo.cc        Thu Jan 09 12:56:28 2014 +0100
@@ -1682,6 +1682,11 @@
   builder.SetInsertPoint (body);
   {
     llvm::Value *one = llvm::ConstantInt::get (index_t, 1);
+    llvm::Value *ione;
+    if (index_t == int_t)
+      ione = one;
+    else
+      ione = llvm::ConstantInt::get (int_t, 1);

     llvm::Value *mat = fn.argument (builder, 0);
     llvm::Value *idx = fn.argument (builder, 1);
@@ -1708,7 +1713,8 @@

     llvm::Value *rcount = builder.CreateExtractValue (mat, 0);
     rcount = builder.CreateLoad (rcount);
-    cond1 = builder.CreateICmpSGT (rcount, one);
+    // ione is needed since rcount is int_t and the compare types must match
+    cond1 = builder.CreateICmpSGT (rcount, ione);
     cond = builder.CreateOr (cond0, cond1);

     llvm::BasicBlock *bounds_error = fn.new_block ("bounds_error", done);

Is there a reason why one couldn't just declare the variable to be int in the first place and avoid the if statement?

if (index_t == int_t)
...
...

The only other place in the block that uses the variable "one" is

    llvm::Value *cond1 = builder.CreateICmpSLT (int_idx, one);

which also has an int object as the first one for comparison.

Rik <rik5>
Project Administrator
Fri 10 Jan 2014 09:30:45 PM UTC, comment #1: 

@Lasse: could you please post a diff of your fix?  Thanks.

Felipe G. Nievinski <fgnievinski>
Thu 09 Jan 2014 12:09:20 PM UTC, original submission:  

When compiling with 64 bit indexing and jit octave crashes at runtime (compilation succeded with the patch from https://savannah.gnu.org/bugs/?41145):

/usr/include/llvm/IR/Instructions.h:972: llvm::ICmpInst::ICmpInst(llvm::CmpInst::Predicate, llvm::Value*, llvm::Value*, const llvm::Twine&): Assertion `getOperand(0)->getType() == getOperand(1)->getType() && "Both operands to ICmp instruction are not of the same type!"' failed.
octave exited with signal 6

I found that the bug was in libinterp/corefcn/jit-typeinfo.cc:

cond1 = builder.CreateICmpSGT (rcount, one);

while one->getType() returns "i64" and rcount->getType() returns "i32". Therefore I created an ione in this scope (as above in line 1613) to match the type of rcond.

Best,

Lasse

Lasse Schuirmann <sils1297>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #30233:  jit_64index.patch added by sils1297 (1KiB - text/x-patch)

 

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 mtmiller (Updated the item)
  • -email is unavailable- added by fgnievinski (Posted a comment)
  • -email is unavailable- added by sils1297 (Submitted the item)
  • -email is unavailable- added by sils1297
  •  

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

    Only project members can vote.

     

     

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-01-14 rik5 StatusPatch Submitted => Fixed
        Open/ClosedOpen => Closed
    2014-01-11 mtmiller StatusNone => Patch Submitted
    2014-01-09 rik5 Carbon-CopyRemoved 72865 => -
    2014-01-09 rik5 CategoryInterpreter => Configuration and Build System
        Item GroupSegfault, Bus Error, etc. => Build Failure
    2014-01-09 sils1297 Attached File- => Added jit_64index.patch, #30233
        Carbon-Copy- => Added k.ohlhus@gmail.com

    Back to the top


    Powered by Savane 3.5