bugKawa - Bugs: bug #39150, AppendValue procedure compiler...

 
 

bug #39150: AppendValue procedure compiler InternalError

Submitter:  Matthieu Vachon <maoueh>
Submitted:  Mon 03 Jun 2013 01:55:30 PM UTC
   
 
Category:  Code generation Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  bothner
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 18 Jul 2013 09:13:52 PM UTC, comment #3: 

Checked in fix and test-case.  Thanks.

Per Bothner <bothner>
Group administrator
Thu 18 Jul 2013 07:20:30 AM UTC, comment #2: 

I've verified this with a slightly simpler test-case:

(define-simple-class <Simple> (<Object>)
  (input type: <String> init-value: ""))

(define (main)

  (let loop ()
    (make <Simple> input: "value")
    (loop)))

The problem appears to be related to the ALLOCATE_ON_STACK optimization.  It's time for bed - I'll try to look at it tomorrow.

Per Bothner <bothner>
Group administrator
Thu 18 Jul 2013 01:39:39 AM UTC, comment #1: 

I saw that you made some inline optimization changes recently. I thought that those changes could have fixed this issue at the same time.

So, I fetched latest version (r7526) and tried it with the snippet below. An improvement has been made since I no longer see the exception when compiling the snippet.

However, the problem now arise when the class is loaded. It's a VerifyError saying the stack trace is inconsistent.


Exception in thread "main" java.lang.VerifyError: (class: org/kawa/test/appendvalueserror, method: test signature: ()Lgn
u/bytecode/Type$NeverReturns;) Inconsistent stack height 1 != 0


Matthieu Vachon <maoueh>
Mon 03 Jun 2013 01:55:30 PM UTC, original submission:  

Assume the following test case:


(define-simple-class <Simple> (<Object>)
  (input type: <String> init-value: ""))

(define (main)
  (define (process)
    (make <Simple> input: "value")
    #t)

  (let loop ()
    (process)
    (loop)))


This does not compile, compiler shows  an `InternalError` where it was compiling fine in version r6989. The bug was introduced in revision r6990.

The thing that happens in new version is that a tail call is process for the `ApplyExp(loop)`, at which point an `emitGoto(label)` is made where the label is the start of the scope of `LambdaExp(loop)`. In the `emitGoto(label)`, we ensure that `code.SP` has same length of `stackTypes` when its not null. But `code.SP` is 1 at point of crash but should be zero.

Removing the `input` field initializer for class <Simple> make compilation works. I dig up further this bug by stepping through the execution path what I found is that a type is pushed on the stack but not pop as it should. When there is not field initializer, the target is `IgnoreTarget` which pop the type if non-void. However, when `input` field initializer is present, the target is a `CheckedTarget` and the type on the stack is not pop and `code.SP` is left at 1. Since it is not 0 as expected, the compiler crash.

I attach the test case I used and also a subset of patch r6990 that can reproduce the error. So the whole patch is not a problem, only a part of it.

Regards,
Matt

P.S Here the start of stack trace for the record:


   caught exception in inline-compiler for #<procedure gnu.kawa.functions.AppendValues> - java.lang.InternalError
    gnu.bytecode.Label.setTypes(Label.java:103)
    gnu.bytecode.CodeAttr.emitGoto(CodeAttr.java:1585)
    gnu.bytecode.CodeAttr.emitTailCall(CodeAttr.java:2482)
    gnu.expr.ApplyExp.compile(ApplyExp.java:422)
    gnu.expr.ApplyExp.compile(ApplyExp.java:132)
    gnu.expr.Expression.compileNotePosition(Expression.java:156)
    gnu.expr.Expression.compileWithPosition(Expression.java:127)
    gnu.expr.BeginExp.compile(BeginExp.java:153)
    gnu.expr.Expression.compileNotePosition(Expression.java:156)
    gnu.expr.Expression.compileWithPosition(Expression.java:127)
    gnu.expr.ApplyExp.compile(ApplyExp.java:333)
    gnu.expr.ApplyExp.compile(ApplyExp.java:132)


Matthieu Vachon <maoueh>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #28234:  appendvalueserror.scm added by maoueh (2KiB - application/octet-stream - test case to reproduce problem & offending changeset (git patch))
file #28235:  AppendValuesErrorsOffendingDiff.patch added by maoueh (4KiB - application/octet-stream - test case to reproduce problem & offending changeset (git patch))

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bothner (Posted a comment)
  • -email is unavailable- added by maoueh (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 logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2013-07-18 bothner StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2013-07-18 bothner StatusNone Confirmed
        Assigned toNone bothner
    2013-06-03 maoueh Attached File- Added appendvalueserror.scm, #28234
        Attached File- Added AppendValuesErrorsOffendingDiff.patch, #28235

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code