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

Fix thread-safety (or document its absence) #6

Open
xmo-odoo opened this issue Feb 24, 2022 · 1 comment
Open

Fix thread-safety (or document its absence) #6

xmo-odoo opened this issue Feb 24, 2022 · 1 comment

Comments

@xmo-odoo
Copy link

Because ptracer uses a context manager, it's easy to use it in a multi-threaded context where the context can be entered and exited from multiple threads concurrently. However it seems to deal rather badly with doing that: because ptracer.context works with an unprotected global (_context), that object can be in a completely inconsistent state because there's a TOCTOU bug on self.enabled.

An easy fix would be to replace enabled with a regular lock (and acquire it in non-blocking, raising if it was not acquired).

It would be nice if ptracer could handle the situation better by having each context "subscribe" to the tracing process, but the asynchronous nature of the reporting likely makes that complicated.

@jparise
Copy link
Collaborator

jparise commented Feb 24, 2022

@elprans do you have any initial thoughts on how to approach this?

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

No branches or pull requests

2 participants