Skip to content

Crashing or data corruption with foldLeft #9900

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
scabug opened this issue Aug 23, 2016 · 3 comments
Closed

Crashing or data corruption with foldLeft #9900

scabug opened this issue Aug 23, 2016 · 3 comments

Comments

@scabug
Copy link

scabug commented Aug 23, 2016

Not sure if this is JVM or Scala compiler issue:

#!/usr/bin/env scala

for (i <- Range(1, 100000)) {
  val l = Array[Byte](-1, -1, -1, -1).foldLeft(0L) { case(l, b) => 
    b & 0xFF
  }
  if (l != 255) {
    println(s"FAIL: got $l after $i iterations")
    sys.exit(1)
  }
}
println("PASS")

OS X + Sun 1.8.0_25 #1 - incorrect return value or crash

$ sw_vers 
ProductName:	Mac OS X
ProductVersion:	10.11.4
BuildVersion:	15E65

$ uname -a
Darwin freya.local 15.4.0 Darwin Kernel Version 15.4.0: Fri Feb 26 22:08:05 PST 2016; root:xnu-3248.40.184~3/RELEASE_X86_64 x86_64

$ java -version
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)

$ ./break-the-scala.scala
FAIL: got -1 after 4691 iterations

$ ./break-the-scala.scala
FAIL: got -1 after 3861 iterations

$ ./break-the-scala.scala
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x000000010f3455af, pid=32384, tid=5891
#
# JRE version: Java(TM) SE Runtime Environment (8.0_25-b17) (build 1.8.0_25-b17)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.25-b02 mixed mode bsd-amd64 compressed oops)
# Problematic frame:
# J 505 C2 Main$$anon$1$$anonfun$1$$anonfun$2.apply(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; (16 bytes) @ 0x000000010f3455af [0x000000010f345520+0x8f]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /Users/jaka/Development/hs_err_pid32384.log
Compiled method (c2)     653  505       4       Main$$anon$1$$anonfun$1$$anonfun$2::apply (16 bytes)
 total in heap  [0x000000010f3453d0,0x000000010f345828] = 1112
 relocation     [0x000000010f3454f8,0x000000010f345520] = 40
 main code      [0x000000010f345520,0x000000010f345640] = 288
 stub code      [0x000000010f345640,0x000000010f345658] = 24
 oops           [0x000000010f345658,0x000000010f345670] = 24
 metadata       [0x000000010f345670,0x000000010f3456b0] = 64
 scopes data    [0x000000010f3456b0,0x000000010f345798] = 232
 scopes pcs     [0x000000010f345798,0x000000010f345808] = 112
 dependencies   [0x000000010f345808,0x000000010f345810] = 8
 nul chk table  [0x000000010f345810,0x000000010f345828] = 24
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#
/Users/jaka/opt/scala/bin/scala: line 21: 32384 Abort trap: 6           "$@"

$ ./break-the-scala.scala
FAIL: got -1 after 3303 iterations

Linux + OpenJDK 1.7.0_95 - passes

$ cat /etc/debian_version 
8.4

$ uname -a
Linux vm-debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2 (2016-04-08) x86_64 GNU/Linux

$ java -version
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
java version "1.7.0_95"
OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-1~deb8u1)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)

$ ./break-the-scala.scala 
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
PASS

$ ./break-the-scala.scala 
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
PASS

$ ./break-the-scala.scala 
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
PASS

Linux + OpenJDK 1.8.0_102 - passes

$ cat /etc/debian_version
8.5

$  uname -a
Linux debianapejcic 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u3 (2016-01-17) x86_64 GNU/Linux

$  java -version
openjdk version "1.8.0_102"
OpenJDK Runtime Environment (build 1.8.0_102-8u102-b14.1-1~bpo8+1-b14)
OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)

$ ./break-the-scala.scala 
PASS

Linux + OpenJDK 1.7.0_111 - always crashes

// same machine as above, just switched JVM

$  java -version
java version "1.7.0_111"
OpenJDK Runtime Environment (IcedTea 2.6.7) (7u111-2.6.7-1~deb8u1)
OpenJDK 64-Bit Server VM (build 24.111-b01, mixed mode)

$ ./break-the-scala.scala 
PASS

$ ./break-the-scala.scala 
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f97b1070347, pid=24295, tid=140289702053632
#
# JRE version: OpenJDK Runtime Environment (7.0_111-b01) (build 1.7.0_111-b01)
# Java VM: OpenJDK 64-Bit Server VM (24.111-b01 mixed mode linux-amd64 compressed oops)
# Derivative: IcedTea 2.6.7
# Distribution: Debian GNU/Linux 8.5 (jessie), package 7u111-2.6.7-1~deb8u1
# Problematic frame:
# J 47 C2 scala.collection.IndexedSeqOptimized$class.foldl(Lscala/collection/IndexedSeqOptimized;IILjava/lang/Object;Lscala/Function2;)Ljava/lang/Object; (34 bytes) @ 0x00007f97b1070347 [0x00007f97b10702c0+0x87]
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/aleksanderpejcic/hs_err_pid24295.log
#
# If you would like to submit a bug report, please include
# instructions on how to reproduce the bug and visit:
#   http://icedtea.classpath.org/bugzilla
#
/usr/bin/scala: line 21: 24295 Aborted                 "$@"
@scabug
Copy link
Author

scabug commented Aug 23, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9900?orig=1
Reporter: Jaka Jancar (JakaJancar)
Affected Versions: 2.11.8

@scabug
Copy link
Author

scabug commented Aug 24, 2016

Arjan Topolovec (arjan) said:
Since this happens so randomly it was a prime candidate for some JIT related JVM bug.
I ran the code using -XX:+PrintCompilation and there is a clear pattern:

  • Main$$anonfun$main$1$$anonfun$1::apply v4 is compiled
  • Main$$anonfun$main$1$$anonfun$1::apply v3 is made not entrant

And at the point of v3 being made not entrant it always crashes the JVM or produces an incorrect result.

@scabug
Copy link
Author

scabug commented Aug 30, 2016

@SethTisue said:
Looks like a JVM bug that is fixed in recent JVM versions, so I suggest we close this (as "not a bug" or "out of scope" or whatever)

@scabug scabug closed this as completed Sep 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant