Skip to content

Conversation

@igladun
Copy link

@igladun igladun commented Dec 3, 2025

This fixes the IWorldState must only be used within scope exception that occurred when VM threads were still running during test cleanup.

Changes

  • Add vmThread.Join() calls after while loops to ensure VM threads complete before TearDown disposes the WorldState scope
  • Add ExecuteSafe helper method to catch ThreadInterruptedException from aborted threads
  • Add ThreadJoinTimeout constant to prevent tests from hanging

Types of changes

What types of changes does your code introduce?

  • Bugfix (a non-breaking change that fixes an issue)
  • New feature (a non-breaking change that adds functionality)
  • Breaking change (a change that causes existing functionality not to work as expected)
  • Optimization
  • Refactoring
  • Documentation update
  • Build-related changes
  • Other: Description

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Notes on testing

All 13 tests ran to completion without the IWorldState must only be used within scope unhandled exception. The 3 failures are pre-existing assertion issues in the test logic itself.

Documentation

Requires documentation update

  • Yes
  • No

If yes, link the PR to the docs update or the issue with the details labeled docs. Remove if not applicable.

Requires explanation in Release Notes

  • Yes
  • No

If yes, fill in the details here. Remove if not applicable.

Remarks

docker run --rm -v "$(pwd):/app" -w /app/src/Nethermind mcr.microsoft.com/dotnet/sdk:10.0-noble dotnet test --project Nethermind.Evm.Test/Nethermind.Evm.Test.csproj -c Debug --filter 'FullyQualifiedName~DebugTracerTests'

Test run summary: Failed!
  total: 13
  failed: 3
  succeeded: 10
  skipped: 0
  duration: 2s 224ms

- Add vmThread.Join() calls after while loops to ensure VM threads complete
  before TearDown disposes the WorldState scope
- Add ExecuteSafe helper method to catch ThreadInterruptedException from
  aborted threads
- Add ThreadJoinTimeout constant to prevent tests from hanging

This fixes the 'IWorldState must only be used within scope' exception that
occurred when VM threads were still running during test cleanup.
@igladun igladun changed the title Fix DebugTracerTests thread synchronization issue (#9606) fix: DebugTracerTests thread synchronization issue [#9606] Dec 3, 2025
@igladun igladun changed the title fix: DebugTracerTests thread synchronization issue [#9606] Fixes #9606: DebugTracerTests thread synchronization issue Dec 3, 2025
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

Successfully merging this pull request may close these issues.

2 participants