trio icon indicating copy to clipboard operation
trio copied to clipboard

fix deadlock when deliver raises

Open richardsheridan opened this issue 3 years ago • 1 comments

I guess I'm building a reputation for finding trio bugs by writing embarrassingly bad code! Raising an exception in deliver argument to start_thread_soon will cause the next usage of the thread cache to deadlock, since the thread has stopped running but the cache thinks it can still assign jobs to it.

Printing out the traceback and carrying on is the obvious thing to do, but I'm open to suggestions on alternatives!

richardsheridan avatar Aug 06 '22 12:08 richardsheridan

Codecov Report

Merging #2389 (efdbcb8) into master (ce4c99e) will increase coverage by 0.87%. The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2389      +/-   ##
==========================================
+ Coverage   98.06%   98.93%   +0.87%     
==========================================
  Files         117      117              
  Lines       16119    16146      +27     
  Branches     3122     3124       +2     
==========================================
+ Hits        15807    15974     +167     
+ Misses        252      123     -129     
+ Partials       60       49      -11     
Impacted Files Coverage Δ
trio/_core/_thread_cache.py 100.00% <100.00%> (ø)
trio/_core/tests/test_thread_cache.py 100.00% <100.00%> (ø)
trio/_core/tests/tutil.py 86.15% <0.00%> (-10.77%) :arrow_down:
trio/_core/_run.py 100.00% <0.00%> (+0.44%) :arrow_up:
trio/tests/test_ssl.py 99.86% <0.00%> (+0.55%) :arrow_up:
trio/tests/test_socket.py 100.00% <0.00%> (+0.65%) :arrow_up:
trio/_core/tests/test_io.py 100.00% <0.00%> (+1.05%) :arrow_up:
trio/tests/test_highlevel_open_tcp_stream.py 100.00% <0.00%> (+1.47%) :arrow_up:
trio/_subprocess_platform/__init__.py 100.00% <0.00%> (+5.71%) :arrow_up:
trio/_highlevel_ssl_helpers.py 100.00% <0.00%> (+11.76%) :arrow_up:
... and 4 more

codecov[bot] avatar Aug 06 '22 12:08 codecov[bot]

print()s in lib code is not really the best imo but it's better than silent exceptions and also better than deadlocks.

Fuyukai avatar Nov 17 '22 16:11 Fuyukai