Skip to content

Fix tests and a thread safety bug - #44

Merged
skr4n merged 2 commits into
mainfrom
fixes
Aug 24, 2026
Merged

Fix tests and a thread safety bug#44
skr4n merged 2 commits into
mainfrom
fixes

Conversation

@skr4n

@skr4n skr4n commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator

Memory corruption issues were discovered when running drive related
tests together parallelly (with cargo test -- --include-ignored).

It was found that the GNU/Linux initialization routine
open_am_linux() was NOT thread safe.
Drive::devices() invokes cdio_get_devices(), which internally
initialized an instance of CdIo_t, making this whole chain unsafe.

Earlier only CdIo_t's C constructor cdio_open() and cleanup
function cdio_destroy() were deemed thread unsafe, due to their use
of a static, and a Mutex was used to uphold safety.
Given that even the underlying intialization routine is also unsafe,
reuse the lock for all routines that in any way initialize CdIo_t.

skr4n added 2 commits August 24, 2026 21:14
Memory corruption issues were discovered when running drive related
tests together parallelly (with `cargo test -- --include-ignored`).

It was found that the GNU/Linux initialization routine
`open_am_linux()` was NOT thread safe.
`Drive::devices()` invokes `cdio_get_devices()`, which internally
initialized an instance of `CdIo_t`, making this whole chain unsafe.

Earlier only `CdIo_t`'s C constructor `cdio_open()` and cleanup
function `cdio_destroy()` were deemed thread unsafe, due to their use
of a static, and a `Mutex` was used to uphold safety.
Given that even the underlying intialization routine is also unsafe,
reuse the lock for all routines that in any way initialize `CdIo_t`.
@skr4n
skr4n merged commit dc89dd4 into main Aug 24, 2026
5 checks passed
@skr4n
skr4n deleted the fixes branch August 26, 2026 11:43
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.

1 participant