Summary

Fixes NullPointerException that occurs in Scala Native when forking 10K fibers, as reported in #9681.

Problem

When running the PromiseSpec - waiter stack safety test on Scala Native, which forks 10,000 fibers, a NullPointerException is thrown in WeakConcurrentBag.addToLongTermStorage. The root cause is that Scala Native’s ConcurrentHashMap.newKeySet() has concurrency issues under high stress scenarios.

Solution

Replace ConcurrentHashMap.newKeySet with Collections.synchronizedSet(new HashSet) in the Scala Native-specific PlatformSpecific.scala. This provides thread-safe set operations without the concurrency bugs present in Scala Native’s ConcurrentHashMap implementation.

Changes

  • core/native/src/main/scala/zio/internal/PlatformSpecific.scala: Modified newConcurrentSet methods to use synchronized HashSet instead of ConcurrentHashMap.newKeySet()

Testing

This fix should allow the PromiseSpec - waiter stack safety test to pass on Scala Native without throwing NullPointerException.

Related Issues

Fixes #9681

/claim #9681

Claim

Total prize pool $150
Total paid $0
Status Pending
Submitted February 24, 2026
Last updated February 24, 2026

Contributors

ER

Erichhhhhcat

@Erichhhhhcat

100%

Sponsors

ZI

ZIO

@ZIO

$150