Skip to content

Fix slcan w IsoTPSoftSocket#4938

Merged
polybassa merged 9 commits intosecdev:masterfrom
BenGardiner:fix-slcan-w-isotpsoftsocket
Feb 28, 2026
Merged

Fix slcan w IsoTPSoftSocket#4938
polybassa merged 9 commits intosecdev:masterfrom
BenGardiner:fix-slcan-w-isotpsoftsocket

Conversation

@BenGardiner
Copy link
Contributor

( I worked on this one with copilot / Claude 4.6 and also some gemini-cli over in BenGardiner#2 )

In addition to the change introduced in #4929 , this PR also introduces testcases to trigger the isotp soft socket regression with sr1() timeout on an MF response to a SF request that I have been experiencing . And then it fixes it by:

  • removing bus filters for slcan interfaces, relying instead on the mux to filter
  • optimizing time under lock and data receive latency in the python-can mux
  • setting timeouts in isotp soft socket that are needed for slow interfaces such as slcan
  • don't call select() (v slow on slcan) if the internal state will do

Verification:

ver driver bg traffic sr1() threaded=? ISOTP DNE result RDID SF req + MF resp result
2.6.0-rc2 candle YES False timeouts ✅ data ✅
2.6.0-rc2 candle YES True hang data
2.6.0-rc2 slcan YES False timeouts ✅ timeouts ❌
2.6.0-rc2 slcan YES True hang timeouts [^1]
2.6.0 candle YES False timeouts ✅ data ✅
2.6.0 candle YES True hang data
2.6.0 slcan YES False timeouts ✅ timeouts [^1] ❌
2.6.0 slcan YES True hang hang
this PR candle YES False timeouts ✅ data ✅
this PR candle YES True timeouts ✅ data ✅
this PR slcan YES False timeouts ✅ data ✅
this PR slcan YES True timeouts ✅ data ✅

builds on top of #4929
fixes (completely) #4838

Copilot AI and others added 5 commits February 27, 2026 09:06
…ang 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>
… (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
Make this timeout scheduler a daemon thread. This should fix the python
3.13 tox failures on windows.
@BenGardiner
Copy link
Contributor Author

hi @polybassa please consider this PR as a replacement for #4929 since it is commits on-top-of it and completely resolves all issues mentioned in #4838

@polybassa
Copy link
Contributor

Luckily we have a lot of unit tests including "stress" tests for the ISOTPSoftSocket. Crossing fingers that it will pass the pipelines!

@codecov
Copy link

codecov bot commented Feb 27, 2026

Codecov Report

❌ Patch coverage is 75.00000% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.64%. Comparing base (2c787cd) to head (1cfc067).
⚠️ Report is 19 commits behind head on master.

Files with missing lines Patch % Lines
scapy/contrib/isotp/isotp_soft_socket.py 77.77% 12 Missing ⚠️
scapy/contrib/cansocket_python_can.py 69.23% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4938      +/-   ##
==========================================
+ Coverage   80.10%   80.64%   +0.53%     
==========================================
  Files         370      370              
  Lines       91733    91976     +243     
==========================================
+ Hits        73482    74172     +690     
+ Misses      18251    17804     -447     
Files with missing lines Coverage Δ
scapy/contrib/cansocket_python_can.py 83.52% <69.23%> (-4.63%) ⬇️
scapy/contrib/isotp/isotp_soft_socket.py 84.18% <77.77%> (-1.01%) ⬇️

... and 32 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BenGardiner
Copy link
Contributor Author

Luckily we have a lot of unit tests including "stress" tests for the ISOTPSoftSocket. Crossing fingers that it will pass the pipelines!

I think the macos failure is unrelated. And almost all the missing code coverage is error handling edge cases.

@polybassa
Copy link
Contributor

Looks great!

@BenGardiner BenGardiner force-pushed the fix-slcan-w-isotpsoftsocket branch from 4519f30 to 9ae0471 Compare February 27, 2026 21:20
@BenGardiner
Copy link
Contributor Author

hmmm ok those pipelines went waaaaay worse than in my test PR here BenGardiner#2 -- I'm looking into why

@BenGardiner BenGardiner force-pushed the fix-slcan-w-isotpsoftsocket branch from 9ae0471 to 1cfc067 Compare February 27, 2026 21:57
@BenGardiner
Copy link
Contributor Author

ok @polybassa .

@polybassa polybassa merged commit b28640f into secdev:master Feb 28, 2026
23 of 24 checks passed
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

Successfully merging this pull request may close these issues.

3 participants