Commit b28640f
Fix slcan w IsoTPSoftSocket (#4938)
* isotp: fix soft socket .select() drops ObjectPipe, causing sr1() to hang in threaded mode
The select() method was filtering out ObjectPipe instances (like the
sniffer's close_pipe) from its return value. This prevented the sniffer's
stop mechanism from working correctly in threaded mode - when sniffer.stop()
sent to close_pipe, the select() method would unblock but not return the
close_pipe, so the sniffer loop couldn't detect the stop signal and had to
rely on continue_sniff timing, causing hangs under load.
The fix includes close_pipe (ObjectPipe) instances in the select return
value, so the sniffer loop properly detects the stop signal via the
'if s is close_pipe: break' check.
Added two new tests:
- sr1 timeout with threaded=True (no response scenario)
- sr1 timeout with threaded=True and background CAN traffic
The new "ISOTPSoftSocket select returns control ObjectPipe" test directly
verifies that ISOTPSoftSocket.select() passes through ready ObjectPipe
instances (e.g. the sniffer's close_pipe). This test deterministically
FAILS without the fix and PASSES with it.
The integration tests (sr1 timeout with threaded=True) are kept for
end-to-end coverage but the race window is too narrow on Linux with
TestSocket to reliably trigger the bug.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Ben Gardiner <ben.l.gardiner@gmail.com>
* isotp: fix potential cause of intermittent test failures where soft socket is garbage collected
* isotpsoft, test: try hard to cleanup background threads in tests
* isotpsoft, test: sr1() soft socket tests incl MF resp, SF req on slow (slcan) interface
introduce mulitple tests to confirm that all the combinations of
filters, threading, slow/fast interfaces work with the isotpsoft socket
in the particularly problematic case of a SF request yielding an MF
respoonse.
The new tests currently fail for slow (slcan) interfaces
* isotpsoft: make TimeoutScheduler._task a daemon thread
Make this timeout scheduler a daemon thread. This should fix the python
3.13 tox failures on windows.
* python-can, mux: special case for slcan: drop bus filters
* isotpsoft: schedule timeouts to work with slow (slcan) interfaces, make close and timeouts more robust
* python-can, mux: limit time under locks, optimize data receive latency
* isotpsoft: optimize for slow (slcan) interfaces: don't call select when the internal state will do
---------
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>1 parent bba4ec0 commit b28640f
File tree
4 files changed
+720
-31
lines changed- scapy/contrib
- isotp
- test
- contrib
4 files changed
+720
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
| |||
55 | 56 | | |
56 | 57 | | |
57 | 58 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
64 | 81 | | |
| 82 | + | |
| 83 | + | |
65 | 84 | | |
| 85 | + | |
66 | 86 | | |
67 | 87 | | |
68 | 88 | | |
69 | 89 | | |
70 | 90 | | |
71 | 91 | | |
72 | 92 | | |
| 93 | + | |
| 94 | + | |
73 | 95 | | |
74 | | - | |
75 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
76 | 104 | | |
77 | 105 | | |
78 | 106 | | |
| |||
132 | 160 | | |
133 | 161 | | |
134 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
135 | 168 | | |
136 | | - | |
137 | | - | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
138 | 174 | | |
139 | 175 | | |
140 | 176 | | |
| |||
161 | 197 | | |
162 | 198 | | |
163 | 199 | | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
168 | 211 | | |
169 | 212 | | |
170 | 213 | | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
171 | 230 | | |
172 | 231 | | |
173 | 232 | | |
| |||
188 | 247 | | |
189 | 248 | | |
190 | 249 | | |
| 250 | + | |
191 | 251 | | |
192 | 252 | | |
193 | 253 | | |
| |||
322 | 382 | | |
323 | 383 | | |
324 | 384 | | |
| 385 | + | |
325 | 386 | | |
326 | 387 | | |
327 | 388 | | |
| |||
333 | 394 | | |
334 | 395 | | |
335 | 396 | | |
336 | | - | |
337 | 397 | | |
338 | 398 | | |
339 | 399 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
169 | | - | |
| 169 | + | |
| 170 | + | |
170 | 171 | | |
171 | 172 | | |
172 | 173 | | |
| |||
202 | 203 | | |
203 | 204 | | |
204 | 205 | | |
205 | | - | |
206 | | - | |
| 206 | + | |
| 207 | + | |
207 | 208 | | |
208 | 209 | | |
209 | 210 | | |
| |||
214 | 215 | | |
215 | 216 | | |
216 | 217 | | |
217 | | - | |
218 | | - | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
219 | 224 | | |
220 | 225 | | |
221 | 226 | | |
| |||
251 | 256 | | |
252 | 257 | | |
253 | 258 | | |
| 259 | + | |
254 | 260 | | |
255 | 261 | | |
256 | 262 | | |
| |||
550 | 556 | | |
551 | 557 | | |
552 | 558 | | |
| 559 | + | |
553 | 560 | | |
554 | 561 | | |
555 | 562 | | |
| |||
592 | 599 | | |
593 | 600 | | |
594 | 601 | | |
595 | | - | |
596 | | - | |
597 | | - | |
598 | | - | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
599 | 613 | | |
600 | | - | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
601 | 622 | | |
602 | 623 | | |
603 | 624 | | |
| |||
643 | 664 | | |
644 | 665 | | |
645 | 666 | | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
646 | 685 | | |
647 | 686 | | |
648 | 687 | | |
649 | 688 | | |
650 | 689 | | |
651 | 690 | | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
652 | 694 | | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
653 | 707 | | |
654 | 708 | | |
655 | 709 | | |
| |||
662 | 716 | | |
663 | 717 | | |
664 | 718 | | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
665 | 722 | | |
666 | 723 | | |
667 | 724 | | |
| |||
866 | 923 | | |
867 | 924 | | |
868 | 925 | | |
| 926 | + | |
869 | 927 | | |
870 | 928 | | |
871 | 929 | | |
| |||
994 | 1052 | | |
995 | 1053 | | |
996 | 1054 | | |
997 | | - | |
998 | | - | |
999 | | - | |
1000 | | - | |
1001 | | - | |
| 1055 | + | |
| 1056 | + | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
| 1060 | + | |
| 1061 | + | |
| 1062 | + | |
| 1063 | + | |
| 1064 | + | |
1002 | 1065 | | |
1003 | 1066 | | |
1004 | 1067 | | |
| |||
0 commit comments