Clojure

NPE when AOTing overrided clojure.core functions

Details

  • Type: Defect Defect
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: Release 1.5, Release 1.6
  • Fix Version/s: Release 1.7
  • Component/s: None
  • Labels:
  • Patch:
    Code
  • Approval:
    Vetted

Description

When performing AOT compilation on a namespace that overrides a clojure.core function without excluding the original clojure.core function from the ns, you get a NullPointerException.

To reproduce:

$ lein new aot-get
$ cd aot-get
$ sed -i s/foo/get/
$ lein compile :all
WARNING: get already refers to: #'clojure.core/get in namespace: aot-get.core, being replaced by: #'aot-get.core/get
Exception in thread "main" java.lang.NullPointerException
	at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4858)
	at clojure.lang.Compiler$DefExpr.emit(Compiler.java:428)
	at clojure.lang.Compiler.compile1(Compiler.java:7152)
	at clojure.lang.Compiler.compile(Compiler.java:7219)
	at clojure.lang.RT.compile(RT.java:398)
	at clojure.lang.RT.load(RT.java:438)
	at clojure.lang.RT.load(RT.java:411)

Cause: DefExpr.parse does not call registerVar for vars overridding clojure.core ones, thus when AOT compiling the var is not registered in the constant table.

Proposed: The attached patch makes DefExpr.parse call registerVar for vars overridding clojure.core ones.

Patch: 0001-fix-CLJ-1241.patch

Activity

Phil Hagelberg made changes -
Field Original Value New Value
Description When performing AOT compilation on a namespace that defines a `get` function without `(:refer-clojure :exclude [get])`, you get a null-pointer exception. To reproduce:

```
$ lein new aot-get
$ cd aot-get
$ sed -i s/foo/get/
$ lein compile :all
```
When performing AOT compilation on a namespace that defines a `get` function without `(:refer-clojure :exclude [get])`, you get a null-pointer exception. To reproduce:

$ lein new aot-get
$ cd aot-get
$ sed -i s/foo/get/
$ lein compile :all
WARNING: get already refers to: #'clojure.core/get in namespace: aot-get.core, being replaced by: #'aot-get.core/get
Exception in thread "main" java.lang.NullPointerException
at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4858)
at clojure.lang.Compiler$DefExpr.emit(Compiler.java:428)
at clojure.lang.Compiler.compile1(Compiler.java:7152)
at clojure.lang.Compiler.compile(Compiler.java:7219)
at clojure.lang.RT.compile(RT.java:398)
at clojure.lang.RT.load(RT.java:438)
at clojure.lang.RT.load(RT.java:411)
[...]
Nicola Mometto made changes -
Attachment 0001-fix-CLJ-1241.patch [ 12082 ]
Nicola Mometto made changes -
Patch Code [ 10001 ]
Alex Miller made changes -
Approval Triaged [ 10120 ]
Description When performing AOT compilation on a namespace that defines a `get` function without `(:refer-clojure :exclude [get])`, you get a null-pointer exception. To reproduce:

$ lein new aot-get
$ cd aot-get
$ sed -i s/foo/get/
$ lein compile :all
WARNING: get already refers to: #'clojure.core/get in namespace: aot-get.core, being replaced by: #'aot-get.core/get
Exception in thread "main" java.lang.NullPointerException
at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4858)
at clojure.lang.Compiler$DefExpr.emit(Compiler.java:428)
at clojure.lang.Compiler.compile1(Compiler.java:7152)
at clojure.lang.Compiler.compile(Compiler.java:7219)
at clojure.lang.RT.compile(RT.java:398)
at clojure.lang.RT.load(RT.java:438)
at clojure.lang.RT.load(RT.java:411)
[...]
When performing AOT compilation on a namespace that defines a `get` function without `(:refer-clojure :exclude [get])`, you get a NullPointerException. To reproduce:

$ lein new aot-get
$ cd aot-get
$ sed -i s/foo/get/
$ lein compile :all
WARNING: get already refers to: #'clojure.core/get in namespace: aot-get.core, being replaced by: #'aot-get.core/get
Exception in thread "main" java.lang.NullPointerException
at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4858)
at clojure.lang.Compiler$DefExpr.emit(Compiler.java:428)
at clojure.lang.Compiler.compile1(Compiler.java:7152)
at clojure.lang.Compiler.compile(Compiler.java:7219)
at clojure.lang.RT.compile(RT.java:398)
at clojure.lang.RT.load(RT.java:438)
at clojure.lang.RT.load(RT.java:411)
[...]
Priority Trivial [ 5 ] Minor [ 4 ]
Alex Miller made changes -
Affects Version/s Release 1.5 [ 10150 ]
Alex Miller made changes -
Labels aot
Rich Hickey made changes -
Approval Triaged [ 10120 ]
Nicola Mometto made changes -
Labels aot aot compiler
Nicola Mometto made changes -
Description When performing AOT compilation on a namespace that defines a `get` function without `(:refer-clojure :exclude [get])`, you get a NullPointerException. To reproduce:

$ lein new aot-get
$ cd aot-get
$ sed -i s/foo/get/
$ lein compile :all
WARNING: get already refers to: #'clojure.core/get in namespace: aot-get.core, being replaced by: #'aot-get.core/get
Exception in thread "main" java.lang.NullPointerException
at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4858)
at clojure.lang.Compiler$DefExpr.emit(Compiler.java:428)
at clojure.lang.Compiler.compile1(Compiler.java:7152)
at clojure.lang.Compiler.compile(Compiler.java:7219)
at clojure.lang.RT.compile(RT.java:398)
at clojure.lang.RT.load(RT.java:438)
at clojure.lang.RT.load(RT.java:411)
[...]
When performing AOT compilation on a namespace that overrides a clojure.core function without excluding the original clojure.core function from the ns, you get a NullPointerException. To reproduce:

$ lein new aot-get
$ cd aot-get
$ sed -i s/foo/get/
$ lein compile :all
WARNING: get already refers to: #'clojure.core/get in namespace: aot-get.core, being replaced by: #'aot-get.core/get
Exception in thread "main" java.lang.NullPointerException
at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4858)
at clojure.lang.Compiler$DefExpr.emit(Compiler.java:428)
at clojure.lang.Compiler.compile1(Compiler.java:7152)
at clojure.lang.Compiler.compile(Compiler.java:7219)
at clojure.lang.RT.compile(RT.java:398)
at clojure.lang.RT.load(RT.java:438)
at clojure.lang.RT.load(RT.java:411)
[...]

This is caused because DefExpr.parse does not call registerVar for vars overridding clojure.core ones, thus when AOT compiling the var is not registered in the constant table.

The attached patch makes DefExpr.parse call registerVar for vars overridding clojure.core ones.
Summary NPE when AOTing overrided clojure.core/get NPE when AOTing overrided clojure.core functions
Aaron Cohen made changes -
Affects Version/s Release 1.6 [ 10157 ]
Alex Miller made changes -
Approval Triaged [ 10120 ]
Description When performing AOT compilation on a namespace that overrides a clojure.core function without excluding the original clojure.core function from the ns, you get a NullPointerException. To reproduce:

$ lein new aot-get
$ cd aot-get
$ sed -i s/foo/get/
$ lein compile :all
WARNING: get already refers to: #'clojure.core/get in namespace: aot-get.core, being replaced by: #'aot-get.core/get
Exception in thread "main" java.lang.NullPointerException
at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4858)
at clojure.lang.Compiler$DefExpr.emit(Compiler.java:428)
at clojure.lang.Compiler.compile1(Compiler.java:7152)
at clojure.lang.Compiler.compile(Compiler.java:7219)
at clojure.lang.RT.compile(RT.java:398)
at clojure.lang.RT.load(RT.java:438)
at clojure.lang.RT.load(RT.java:411)
[...]

This is caused because DefExpr.parse does not call registerVar for vars overridding clojure.core ones, thus when AOT compiling the var is not registered in the constant table.

The attached patch makes DefExpr.parse call registerVar for vars overridding clojure.core ones.
When performing AOT compilation on a namespace that overrides a clojure.core function without excluding the original clojure.core function from the ns, you get a NullPointerException.

To reproduce:

{code}
$ lein new aot-get
$ cd aot-get
$ sed -i s/foo/get/
$ lein compile :all
WARNING: get already refers to: #'clojure.core/get in namespace: aot-get.core, being replaced by: #'aot-get.core/get
Exception in thread "main" java.lang.NullPointerException
at clojure.lang.Compiler$ObjExpr.emitVar(Compiler.java:4858)
at clojure.lang.Compiler$DefExpr.emit(Compiler.java:428)
at clojure.lang.Compiler.compile1(Compiler.java:7152)
at clojure.lang.Compiler.compile(Compiler.java:7219)
at clojure.lang.RT.compile(RT.java:398)
at clojure.lang.RT.load(RT.java:438)
at clojure.lang.RT.load(RT.java:411)
{code}

*Cause:* DefExpr.parse does not call registerVar for vars overridding clojure.core ones, thus when AOT compiling the var is not registered in the constant table.

*Proposed:* The attached patch makes DefExpr.parse call registerVar for vars overridding clojure.core ones.

*Patch:* 0001-fix-CLJ-1241.patch
Rich Hickey made changes -
Priority Minor [ 4 ] Major [ 3 ]
Rich Hickey made changes -
Fix Version/s Release 1.7 [ 10250 ]
Approval Triaged [ 10120 ] Vetted [ 10003 ]

People

Vote (1)
Watch (5)

Dates

  • Created:
    Updated: