Clojure

NPE when AOTing overrided clojure.core functions

Details

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

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 aot compile a namespace like "(ns x) (defn get [])"

For example:

$ 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

Screened by: Alex Miller

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 -
Priority Trivial [ 5 ] Minor [ 4 ]
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)
[...]
Approval Triaged [ 10120 ]
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 -
Summary NPE when AOTing overrided clojure.core/get NPE when AOTing overrided clojure.core functions
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.
Aaron Cohen made changes -
Affects Version/s Release 1.6 [ 10157 ]
Alex Miller made changes -
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
Approval Triaged [ 10120 ]
Rich Hickey made changes -
Priority Minor [ 4 ] Major [ 3 ]
Rich Hickey made changes -
Approval Triaged [ 10120 ] Vetted [ 10003 ]
Fix Version/s Release 1.7 [ 10250 ]
Alex Miller made changes -
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:

{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
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 aot compile a namespace like "(ns x) (defn get [])"

For example:
{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

*Screened by:* Alex Miller
Approval Vetted [ 10003 ] Screened [ 10004 ]
Rich Hickey made changes -
Approval Screened [ 10004 ] Ok [ 10007 ]
Stuart Halloway made changes -
Status Open [ 1 ] Closed [ 6 ]
Resolution Completed [ 1 ]

People

Vote (2)
Watch (6)

Dates

  • Created:
    Updated:
    Resolved: