Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
This repository was archived by the owner on Jan 12, 2024. It is now read-only.

Simulator tests intermittently fail with Access Violation crashes #335

Description

Describe the bug

Our simulator tests in src\Simulation\Simulators.Tests sometimes crash with an Access Violation when calling into the native simulator code.

To Reproduce

The crash is intermittent, but most often observed by QSimMultiThreading test, since that explicitly tests the multithreaded support.

Expected behavior

Tests should execute successfully

Actual behavior

Test host process crashes intermittently.

Additional context
Because psis is a global vector, it's shared across all the tests in the process, which xUnit will run in parallel. If a new test starts and goes to allocate a simulator and there are no empty slots in the vector, it triggers a call to push_back, and if another thread is accessing the vector at the same time it will get an access violation. SetSeed and the like follow the same pattern where it takes the simulator id as the first argument, then uses it like this: psis[id]->seed(s)
If the new size of the vector is greater than it's capacity, the whole internal storage is reallocated. From the push_back docs:

Data races
The container is modified.
If a reallocation happens, all contained elements are modified.
Otherwise, no existing element is accessed, and concurrently accessing or modifying them is safe.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions