Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure init() to be safe again. #9

Merged
merged 2 commits into from
Jun 14, 2023
Merged

Configure init() to be safe again. #9

merged 2 commits into from
Jun 14, 2023

Conversation

Anders429
Copy link
Owner

This removes the unsafe from init() that was added in #8. There are two things to consider here:

  1. After further research, it's been determined that the use of the debug registers by other code does not pose a data race, but simply a race condition. Meaning each write to an individual byte cannot be interrupted, and therefore each write cannot be a race. It is still important for this library to ensure log calls disable IME, for the same reasons set forth in Shared global state provides synchronization issues #4, but the fact that this code can overwrite data set by other code is not technically a data race, and therefore not unsafe.
  2. This PR disables IME when setting the logger and max level, making those calls safe. This is what all user code should have done after Mark init() as an unsafe function. #8 anyways (and before, since apparently the log initialization functions were likely not working correctly prior to log 0.4.19), so it makes more sense to simply handle it here.

@Anders429 Anders429 merged commit 967cadd into dev Jun 14, 2023
12 checks passed
@Anders429 Anders429 deleted the safety branch June 14, 2023 01:00
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.

None yet

1 participant