From e16864f2e7b0bfd9191e320b66f3e0e1435d0392 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Wed, 27 Nov 2013 08:53:52 -0500 Subject: [PATCH] Drop Thread.getName from use in computeID(thread) in TrapExit SecurityManager to fix #997. --- run/src/main/scala/sbt/TrapExit.scala | 4 +++- sbt/src/sbt-test/run/awt/A.scala | 5 +++++ sbt/src/sbt-test/run/awt/test | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 sbt/src/sbt-test/run/awt/A.scala create mode 100644 sbt/src/sbt-test/run/awt/test diff --git a/run/src/main/scala/sbt/TrapExit.scala b/run/src/main/scala/sbt/TrapExit.scala index ce761b002..def4caebc 100644 --- a/run/src/main/scala/sbt/TrapExit.scala +++ b/run/src/main/scala/sbt/TrapExit.scala @@ -73,7 +73,9 @@ object TrapExit /** Computes an identifier for a Thread that has a high probability of being unique within a single JVM execution. */ private def computeID(t: Thread): ThreadID = // can't use t.getId because when getAccess first sees a Thread, it hasn't been initialized yet - s"${hex(System.identityHashCode(t))}:${t.getName}" + // can't use t.getName because calling it on AWT thread in certain circumstances generates a segfault (#997): + // Apple AWT: +[ThreadUtilities getJNIEnvUncached] attempting to attach current thread after JNFObtainEnv() failed + s"${hex(System.identityHashCode(t))}" /** Waits for the given `thread` to terminate. However, if the thread state is NEW, this method returns immediately. */ private def waitOnThread(thread: Thread, log: Logger) diff --git a/sbt/src/sbt-test/run/awt/A.scala b/sbt/src/sbt-test/run/awt/A.scala new file mode 100644 index 000000000..d7eba868b --- /dev/null +++ b/sbt/src/sbt-test/run/awt/A.scala @@ -0,0 +1,5 @@ +object O { + def main(argv: Array[String]) { + new java.awt.Color(0,0,0) + } +} diff --git a/sbt/src/sbt-test/run/awt/test b/sbt/src/sbt-test/run/awt/test new file mode 100644 index 000000000..540d707bb --- /dev/null +++ b/sbt/src/sbt-test/run/awt/test @@ -0,0 +1,3 @@ +# in #997, creating an instance of an AWT class triggers a segfault +# this verifies that is fixed +> run