Skip to content

Fix: smart memory managing against memory corruption when tests shuffle#86

Closed
metaq3 wants to merge 1 commit into
snems:masterfrom
metaq3:meta/fix/segfault-on-shuffled-tests
Closed

Fix: smart memory managing against memory corruption when tests shuffle#86
metaq3 wants to merge 1 commit into
snems:masterfrom
metaq3:meta/fix/segfault-on-shuffled-tests

Conversation

@metaq3

@metaq3 metaq3 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Important

READ THIS! Before you merge and even read all of stuff I wrote below, please, take a note about much, much easier solution. You could just provide --order decl arg to the test binary. If you don't wan't to use Catch2 features and ensuring your tests are state-independent is not important for you, consider using this instead of my PR.

Some tests are divided into groups that share same memory chunk. They rely on it and assume it's never touched by other tests. But Catch2 may shuffle tests from different groups with each other to ensure they're state independent. This causes them to corrupt memory of each other.

It was fixed with memory forks. Each test group contains own fork of zone memory, and this fork is activated every time test needs group's one. Forks are not freed until all test finish, though.

Some tests are divided into groups that share same memory chunk. They
rely on it and assume it's never touched by other tests. Catch2 may
shuffle tests from different groups with each other to ensure they're
state independent. This causes them to corrupt memory of each other.

It was fixed with memory forks. Each test group contains own fork of
zone memory, and this fork is activated every time test needs one.
@metaq3 metaq3 force-pushed the meta/fix/segfault-on-shuffled-tests branch from 2586a2f to 67b1b52 Compare June 19, 2026 06:43
@metaq3

metaq3 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

I missed point in the PR description, but for the record: yes, I have googled some way of turning off shuffles within the test group, but found nothing. Seems that Catch2 is incapable of such a thing.

@snems

snems commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Thank you!
I'm convinced that no tests should interfere with each other, so I fixed it in another way in #87.

@metaq3

metaq3 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor Author

I fixed tests for MinGW in #85. This PR has no need now.

@metaq3 metaq3 closed this Jun 20, 2026
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