Uh oh!
There was an error while loading. Please reload this page.
Adding iostream.h thread-safety documentation. - #2995
Conversation
rwgk
commented
May 6, 2021
YannickJadoul
commented
May 6, 2021
Remove a test because it triggers a failure? Why not just follow the docs you are adding in literally the same PR and add a lock to the test? At least that would illustrate and test the docs you've just written. |
rwgk
commented
May 6, 2021
That's what I tried first. Pieter replied with a "defeats the point of the test" comment here: #2982 (comment) Basically, it would make that part of the unit test just a demo for how to do locking. I think it's better removed. |
henryiii
commented
May 7, 2021
Can we just disable the test for Windows? We've never seen it flake on anything but MSVC. |
rwgk
commented
May 7, 2021
Thanks Henry, we could, but
Two-and-a-half ideas:
Please let me know what you prefer and I'll change this PR accordingly. |
henryiii
commented
May 8, 2021
My preference would be for idea 2 (test with mutexes) - I'm not that worried about stdlib includes in a test file, and it makes it a really nice example (if it works). But other than that, given the two points you listed, the current form of the PR is acceptable if not quite as ideal as that would be. |
rwgk
commented
May 8, 2021
Thanks Henry, I'll restore |
tttapa
commented
May 8, 2021
The changes to the documentation look good to me. Maybe I would be more specific about this sentence:
Perhaps “protected using a mutex” is clearer than “locked”? I agree that it might be a good idea to keep a multithreaded test as an example on how to do the locking correctly. In that case I would try to isolate it from the other iostream tests, i.e. don't add locks to the existing functions I've thought about it some more, and locking in user code could prove problematic: The following sequence now causes deadlock: Keeping this in mind, adding the locking to |
rwgk
commented
May 11, 2021
Hi All, please take another look. The When I started this PR, my main interest was to get rid of the test_iostream Windows flakiness and the TSAN error. I don't have a vested interest beyond those two points. Currently, iostream.h is not used at Google. The TSAN error is definitely gone, I ran the test 1000 times. I assume the Windows flakiness is also gone, although we may have to wait and see to be sure. |
rwgk
commented
Jun 4, 2021
Small update, the Windows flake still happens, although much more rarely after #2982 was merged. Here is one example I just observed: https://github.com/pybind/pybind11/pull/3023/checks?check_run_id=2743130279 |
rwgk
commented
Jun 6, 2021
Here is another one, different Python version (3.8 vs 2.7), different C++ standard (11 vs. 17), but same symptom: https://github.com/pybind/pybind11/pull/3030/checks?check_run_id=2758466712 |
rwgk
commented
Jun 16, 2021
I just hit on this again, after not seeing these errors for quite a long time: This was with ASAN (not TSAN). @henryiii I feel we really need to warn users prominently. |
e533a17 to
307f8a8Comparerwgk
commented
Jul 12, 2021
Thanks Henry! |
…ell check was added after the CI for PR pybind#2995 last ran.
Description
For full background see the discussions under PR #2982 and this PR.
This PR resolves the clang ThreadSanitizer (tsan) error reported under #2754, but only in stop-gap fashion.
#HelpAppreciated: Work on iostream.h thread safety.
Suggested changelog entry: