scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

NullPointerException in Scala 2.8 and 2.9RC1 with 64bit Java 1.7.0-ea-b136 (Windows 7 x64) #4449

Closed scabug closed 13 years ago

scabug commented 13 years ago

Hello.

Running scalac on my 64bit Java 7 install throws a NPE:

C:\_\>scalac
error: java.lang.NullPointerException
        at scala.collection.immutable.HashSet$$HashTrieSet.updated0(HashSet.scala:228)
        at scala.collection.immutable.HashSet.$$plus(HashSet.scala:54)
        at scala.collection.immutable.HashSet.$$plus(HashSet.scala:32)
        at scala.collection.mutable.SetBuilder.$$plus$$eq(SetBuilder.scala:24)
        at scala.collection.mutable.SetBuilder.$$plus$$eq(SetBuilder.scala:22)
        at scala.collection.TraversableLike$$$$anonfun$$map$$1.apply(TraversableLike.scala:245)
        at scala.collection.TraversableLike$$$$anonfun$$map$$1.apply(TraversableLike.scala:245)
        at scala.collection.mutable.HashSet.foreach(HashSet.scala:75)
        at scala.collection.TraversableLike$$class.map(TraversableLike.scala:245)
        at scala.collection.mutable.HashSet.scala$$collection$$SetLike$$$$super$$map(HashSet.scala:42)
        at scala.collection.SetLike$$class.map(SetLike.scala:91)
        at scala.collection.mutable.HashSet.map(HashSet.scala:42)
        at scala.tools.nsc.CompilerCommand.helpSyntaxColumnWidth(CompilerCommand.scala:30)
        at scala.tools.nsc.CompilerCommand.format(CompilerCommand.scala:34)
        at scala.tools.nsc.CompilerCommand.helpStr$$1(CompilerCommand.scala:51)
        at scala.tools.nsc.CompilerCommand$$$$anonfun$$createUsageMsg$$1.apply(CompilerCommand.scala:60)
        at scala.tools.nsc.CompilerCommand$$$$anonfun$$createUsageMsg$$1.apply(CompilerCommand.scala:60)
        at scala.collection.TraversableLike$$$$anonfun$$map$$1.apply(TraversableLike.scala:245)
        at scala.collection.TraversableLike$$$$anonfun$$map$$1.apply(TraversableLike.scala:245)
        at scala.collection.LinearSeqOptimized$$class.foreach(LinearSeqOptimized.scala:59)
        at scala.collection.immutable.List.foreach(List.scala:45)
        at scala.collection.TraversableLike$$class.map(TraversableLike.scala:245)
        at scala.collection.immutable.List.map(List.scala:45)
        at scala.tools.nsc.CompilerCommand.createUsageMsg(CompilerCommand.scala:60)
        at scala.tools.nsc.CompilerCommand.usageMsg(CompilerCommand.scala:67)
        at scala.tools.nsc.Main$$.process(Main.scala:101)
        at scala.tools.nsc.Main$$.main(Main.scala:123)
        at scala.tools.nsc.Main.main(Main.scala)

Exception in thread "main" java.lang.NullPointerException
        at scala.collection.immutable.HashSet$$HashTrieSet.updated0(HashSet.scala:228)
        at scala.collection.immutable.HashSet.$$plus(HashSet.scala:54)
        at scala.collection.immutable.HashSet.$$plus(HashSet.scala:32)
        at scala.collection.mutable.SetBuilder.$$plus$$eq(SetBuilder.scala:24)
        at scala.collection.mutable.SetBuilder.$$plus$$eq(SetBuilder.scala:22)
        at scala.collection.TraversableLike$$$$anonfun$$map$$1.apply(TraversableLike.scala:245)
        at scala.collection.TraversableLike$$$$anonfun$$map$$1.apply(TraversableLike.scala:245)
        at scala.collection.mutable.HashSet.foreach(HashSet.scala:75)
        at scala.collection.TraversableLike$$class.map(TraversableLike.scala:245)
        at scala.collection.mutable.HashSet.scala$$collection$$SetLike$$$$super$$map(HashSet.scala:42)
        at scala.collection.SetLike$$class.map(SetLike.scala:91)
        at scala.collection.mutable.HashSet.map(HashSet.scala:42)
        at scala.tools.nsc.CompilerCommand.helpSyntaxColumnWidth(CompilerCommand.scala:30)
        at scala.tools.nsc.CompilerCommand.format(CompilerCommand.scala:34)
        at scala.tools.nsc.CompilerCommand.helpStr$$1(CompilerCommand.scala:51)
        at scala.tools.nsc.CompilerCommand$$$$anonfun$$createUsageMsg$$1.apply(CompilerCommand.scala:60)
        at scala.tools.nsc.CompilerCommand$$$$anonfun$$createUsageMsg$$1.apply(CompilerCommand.scala:60)
        at scala.collection.TraversableLike$$$$anonfun$$map$$1.apply(TraversableLike.scala:245)
        at scala.collection.TraversableLike$$$$anonfun$$map$$1.apply(TraversableLike.scala:245)
        at scala.collection.LinearSeqOptimized$$class.foreach(LinearSeqOptimized.scala:59)
        at scala.collection.immutable.List.foreach(List.scala:45)
        at scala.collection.TraversableLike$$class.map(TraversableLike.scala:245)
        at scala.collection.immutable.List.map(List.scala:45)
        at scala.tools.nsc.CompilerCommand.createUsageMsg(CompilerCommand.scala:60)
        at scala.tools.nsc.CompilerCommand.usageMsg(CompilerCommand.scala:67)
        at scala.tools.nsc.Main$$.process(Main.scala:101)
        at scala.tools.nsc.Main$$.main(Main.scala:123)
        at scala.tools.nsc.Main.main(Main.scala)

My PATH variables are set to use the 64bit JRE as the default. If I explicitly run scalac under the 32bit JRE, with this line:

C:\_\>"C:\Program Files (x86)\Java\jre7\bin\java.exe" -Dscala.home="C:\PROGRA~2\Scal
a" -cp "C:\PROGRA~2\Scala\lib\jline.jar;C:\PROGRA~2\Scala\lib\scala-compiler.jar;C:\PROGRA~2\Scala\lib\scala-dbc.jar;C:\PROGRA~2\Scala
\lib\scala-library.jar;C:\PROGRA~2\Scala\lib\scala-swing.jar;C:\PROGRA~2\Scala\lib\scalap.jar" scala.tools.nsc.Main

.. everything works fine.

The problem first occured in Scala 2.8.1, then I updated to 2.9-RC1 and the issue is identical.

Now, I'm not sure if it's maybe a JRE 7 bug, but seeing only Scala sources in the NPE stacktrace, I wanted to report it here, just in case.

Scala itself seems to run fine under 64bit Java 7. However, when I type "import scala.collection.immutable.HashSet" on the REPL, I get this:

java.lang.NullPointerException
        at scala.collection.immutable.HashMap$$HashTrieMap.updated0(HashMap.scala:269)
        at scala.collection.immutable.HashMap.$$plus(HashMap.scala:53)
        at scala.collection.immutable.HashMap.$$plus(HashMap.scala:36)
        at scala.collection.mutable.MapBuilder.$$plus$$eq(MapBuilder.scala:28)
        at scala.collection.mutable.MapBuilder.$$plus$$eq(MapBuilder.scala:24)
        at scala.collection.generic.Growable$$$$anonfun$$$$plus$$plus$$eq$$1.apply(Growable.scala:48)
        at scala.collection.generic.Growable$$$$anonfun$$$$plus$$plus$$eq$$1.apply(Growable.scala:48)
        at scala.collection.IndexedSeqOptimized$$class.foreach(IndexedSeqOptimized.scala:34)
        at scala.collection.mutable.WrappedArray.foreach(WrappedArray.scala:33)
        at scala.collection.generic.Growable$$class.$$plus$$plus$$eq(Growable.scala:48)
        at scala.collection.mutable.MapBuilder.$$plus$$plus$$eq(MapBuilder.scala:24)
        at scala.collection.generic.MapFactory.apply(MapFactory.scala:48)
        at scala.tools.nsc.typechecker.Modes$$class.$$init$$(Modes.scala:111)
        at scala.tools.nsc.Global$$analyzer$$.<init>(Global.scala:347)
        at scala.tools.nsc.Global.analyzer(Global.scala:347)
        at scala.tools.nsc.Global.computeInternalPhases(Global.scala:554)
        at scala.tools.nsc.Global.computePhaseDescriptors(Global.scala:593)
        at scala.tools.nsc.Global.phaseDescriptors(Global.scala:600)
        at scala.tools.nsc.Global$$Run.<init>(Global.scala:689)
        at scala.tools.nsc.interpreter.IMain.scala$$tools$$nsc$$interpreter$$IMain$$$$_initialize(IMain.scala:114)
        at scala.tools.nsc.interpreter.IMain$$$$anonfun$$initialize$$1.apply$$mcZ$$sp(IMain.scala:148)
        at scala.tools.nsc.interpreter.IMain$$$$anonfun$$initialize$$2.apply(IMain.scala:148)
        at scala.tools.nsc.interpreter.IMain$$$$anonfun$$initialize$$2.apply(IMain.scala:148)
        at scala.concurrent.ThreadRunner$$$$anon$$2$$$$anonfun$$run$$2.apply(ThreadRunner.scala:45)
        at scala.concurrent.ThreadRunner.scala$$concurrent$$ThreadRunner$$$$tryCatch(ThreadRunner.scala:31)
        at scala.concurrent.ThreadRunner$$$$anon$$2.run(ThreadRunner.scala:45)
        at java.lang.Thread.run(Thread.java:722)

The repl compiler has crashed spectacularly. Shall I replay your
session? I can re-run all lines except the last one.
[y/n]Exception in thread "main" java.lang.RuntimeException: No char-based input in SimpleReader
        at scala.sys.package$$.error(package.scala:27)
        at scala.tools.nsc.interpreter.SimpleReader.readOneKey(SimpleReader.scala:35)
        at scala.tools.nsc.interpreter.SimpleReader.readOneKey(SimpleReader.scala:13)
        at scala.tools.nsc.interpreter.InteractiveReader$$class.readYesOrNo(InteractiveReader.scala:30)
        at scala.tools.nsc.interpreter.SimpleReader.readYesOrNo(SimpleReader.scala:13)
        at scala.tools.nsc.interpreter.InteractiveReader$$class.readAssumingNo(InteractiveReader.scala:34)
        at scala.tools.nsc.interpreter.SimpleReader.readAssumingNo(SimpleReader.scala:13)
        at scala.tools.nsc.interpreter.ILoop$$$$anonfun$$31.apply(ILoop.scala:422)
        at scala.tools.nsc.interpreter.ILoop$$$$anonfun$$31.apply(ILoop.scala:401)
        at scala.tools.nsc.interpreter.ILoop.loop(ILoop.scala:450)
        at scala.tools.nsc.interpreter.ILoop.process(ILoop.scala:730)
        at scala.tools.nsc.MainGenericRunner$$.runTarget$$1(MainGenericRunner.scala:72)
        at scala.tools.nsc.MainGenericRunner$$.process(MainGenericRunner.scala:85)
        at scala.tools.nsc.MainGenericRunner$$.main(MainGenericRunner.scala:33)
        at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

(it crashes before giving me a chance to type y/n)

Scala: 2.9.0.RC1 Java: Java 1.7.0-ea-b136 (64 and 32bit) OS: Windows 7 Professional x64

Thanks and I apologize in advance if this is a known issue (I searched trac and found nothing relevant).

scabug commented 13 years ago

Imported From: https://issues.scala-lang.org/browse/SI-4449?orig=1 Reporter: Sandro Grii (sandrogrzicic)

scabug commented 13 years ago

@cunei said: I will have to close this ticket as "invalid". The Java 7 Early Access code is not production quality, and these problems may very well be transient. In order to check the situation, I installed a fresh copy same version of Java 7 on a 64-bit Windows 7, and the first run of "scalac" quite simply caused an internal failure in the JVM (see below). We cannot even start any debugging under these circumstances: the Java 7 code is just not stable enough at this time.

C:\Users\cunei>scalac
"java" -Xmx256M -Xms32M -Dscala.home="C:\PROGRA~1\scala\bin\.." -Denv.emacs="" -cp "C:\PROGRA~1\scala\bin\..\lib\jline.jar;C:\PROGRA~1\scala\bin\..\lib\scala-compiler.jar;C:\PROGRA~1\scala\bin\..\lib\scala-dbc.jar;C:\PROGRA~1\scala\bin\..\lib\scala-library.jar;C:\PROGRA~1\scala\bin\..\lib\scala-swing.jar;C:\PROGRA~1\scala\bin\..\lib\scalap.jar" scala.tools.nsc.Main
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000000262c450, pid=2836, tid=1444
#
# JRE version: 7.0-b136
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.0-b06 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# j  scala.collection.immutable.HashSet$$HashTrieSet.updated0(Ljava/lang/Object;II)Lscala/collection/immutable/HashSet;+84
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# C:\Users\cunei\hs_err_pid2836.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#
scabug commented 13 years ago

Sandro Grii (sandrogrzicic) said: Replying to [comment:1 cunei]:

Ok, agreed. I just thought it might be in some remote way related to Scala. By the way, your error is exactly the same as mine, but the output format is somehow different (note the line after "Problematic frame:").

Thanks. I hope the next build (or one of the next builds) of the 64bit Java 7 JRE fixes this (obviously Java) bug. :)