bugKawa - Bugs: bug #18909, Recursive call to function in...

 
 

bug #18909: Recursive call to function in closure causes NullPointerException

Submitted by:  Chris Wegrzyn <cwegrzyn>
Submitted on:  Tue 30 Jan 2007 03:01:58 PM UTC  
 
Category: Code generationSeverity: 3 - Normal
Item Group: Compile-time exceptionStatus: Fixed
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Thu 01 Mar 2007 07:39:11 PM UTC, comment #2:

Thanks for tracking this down! I tried a simpler patch (merging compileChildMethods info compileEnd), and it appears to work. I checked that in, and also a testcase derived from yours.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Tue 30 Jan 2007 08:16:07 PM UTC, comment #1:

It looks like this happens because the constructor and the apply methods are generated before the code for child methods. I have attached a patch that attempts to fix this by moving these two passes out of compileEnd into a compileAfter function, then running compileAfter wherever compileEnd was called, but after compileChildMethods.

Works for me, but not well tested.

(file #11893)

Chris Wegrzyn <cwegrzyn>
Tue 30 Jan 2007 03:01:58 PM UTC, original submission:

The following code raises a NullPointerException:

(define (outerproc foo)
(define (innerproc)
(if foo
(lambda () (innerproc))
'()))
(innerproc))

(define destroy ((outerproc #t)))

If you remove the reference to the closure of innerproc (by replacing foo with #t), the code executes as expected, returning a procedure which generates a procedure and so on. Perhaps innerproc isn't being correctly stored/retrieved from its closure?

For reference, the full stack trace is
java.lang.NullPointerException
at gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:220)
at gnu.mapping.Procedure.apply(Procedure.java:103)
at gnu.mapping.Procedure.apply(Procedure.java:95)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:251)
at gnu.mapping.CallContext.getFromContext(CallContext.java:280)
at gnu.expr.Expression.eval(Expression.java:24)
at gnu.expr.Expression.eval(Expression.java:41)
at gnu.expr.SetExp.apply(SetExp.java:103)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:205)
at kawa.Shell.run(Shell.java:230)
at kawa.standard.load.loadSource(load.java:110)
at kawa.standard.load.apply(load.java:210)
at kawa.Shell.runFile(Shell.java:308)
at kawa.repl.processArgs(repl.java:251)
at kawa.repl.main(repl.java:828)

Chris Wegrzyn <cwegrzyn>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #11893:  closure-crash.patch added by cwegrzyn (2KiB - text/x-patch - patch against r5885)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 01 Mar 2007 07:39:11 PM UTCbothnerStatusNone=>Fixed
      Assigned toNone=>bothner
      Open/ClosedOpen=>Closed
    Tue 30 Jan 2007 08:16:07 PM UTCcwegrzynAttached File-=>Added closure-crash.patch, #11893

    Back to the top


    Powered by Savane 3.1-cleanup1