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

🐛Add mutex control for printf and cout #570

Merged
merged 2 commits into from
May 8, 2023

Conversation

ryan-doan
Copy link
Contributor

@ryan-doan ryan-doan commented Apr 18, 2023

Summary:

Added mutex control to protect printf and cout from causing utf-8 encoding errors due to race conditions. This is done by preventing context switches while prvWriteBytesToBuffer() and prvReadBytesToBuffer() is executing.

Motivation:

References (optional):

BUG: Multiple threads writing to stdout can cause encoding errors #500

Test Plan:

It is difficult to verify that the changes entirely prevents utf-8 encoding errors since the race condition is difficult to reproduce consistently.

  • Compile.
  • Implementation prevents utf-8 encoding from happening.

Copy link
Contributor

@noam987 noam987 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@noam987 noam987 merged commit 4c9b90b into develop-pros-4 May 8, 2023
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