Skip to content

Commit

Permalink
Initialize scala.util.control.NonFatal in Builder (#4195) (#4197)
Browse files Browse the repository at this point in the history
Chisel includes logic to trim NonFatal stack traces. OutOfMemoryErrors
(e.g. from running out of heap or stack) can cause weird issues where
because the JVM is out of memory, scala.util.control.NonFatal cannot be
loaded to compare to and then the JVM masks the real OutOfMemoryError by
throwing a LinkageError.

(cherry picked from commit 0baa8fd)

Co-authored-by: Jack Koenig <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
mergify[bot] and jackkoenig authored Jun 20, 2024
1 parent c9957f9 commit 805bf30
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/src/main/scala/chisel3/internal/Builder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1022,8 +1022,12 @@ private[chisel3] object Builder extends LazyLogging {
forceModName: Boolean
): (Circuit, T) = {
dynamicContextVar.withValue(Some(dynamicContext)) {
ViewParent: Unit // Must initialize the singleton in a Builder context or weird things can happen
// in tiny designs/testcases that never access anything in chisel3.internal
// Must initialize the singleton in a Builder context or weird things can happen
// in tiny designs/testcases that never access anything in chisel3.internal.
ViewParent: Unit
// Must initialize the singleton or OutOfMemoryErrors and StackOverflowErrors will instead report as
// "java.lang.NoClassDefFoundError: Could not initialize class scala.util.control.NonFatal$".
scala.util.control.NonFatal: Unit
logger.info("Elaborating design...")
val mod =
try {
Expand Down

0 comments on commit 805bf30

Please sign in to comment.