Sorry — there’s a small misunderstanding around “crash.” By “crash,” I meant a CPython-internal bug that takes down the whole interpreter, so I was saying you basically don’t get that kind of crash because of the GIL. In that thread, “crash” means a Python exception raised, and that does happen.
and i asked if with or without gil you can get crash.
Yes — it can “crash” both with and without the GIL; I’ve verified that.
The cause is this pattern:
if i in state:
time.sleep(0.0)
del state[i]
It looks like you check that i is in state and then operate on it. But in reality, worker2 can clear state in between, so there’s a data race / thread-safety issue — and that’s what triggers the crash.
i want to see if i can get possible all kinds of issues
Fundamentally, GIL-related problems mostly are: two threads operating on the same object without proper synchronization (locks, atomic operations, etc.).