Suppress tcp-stream garbage referring to a closed fd. #362
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On errornous situation,
make-tcp-socket
function seems to make a temporal tcp-stream object referring a closed FD.I saw some strange crashes probably because of it.
This PR tries to release the objects correctly.
Consider
make-tcp-socket
failed by 'Connection Refused'.In this situation,
%socket-connect
raises an error. If I selected to abort, stack unwinds, and the FD will be closed by theunwind-protect
ed form. But the socket object made by this function still exists in memory and continues to refer the closed FD. After that, I sometimes see CCL randomly crashes at processing I/Os.Here is a case going to crash I found on my machine (MacOS High Sierra 10.13.6).
MacOS's crash report indicated
close
caused this crash:So I tried to take a trace around
ccl::fd-close
. I got below:I think, when the GC collects the temporal socket object, GC tries to close the already closed FD, and strangely go to crash...?
I found resembled codes in
make-udp-socket
andmake-stream-file-socket
, so I applied same fixes to them.This problem is repored at a thread in 5ch.net (Japanese BBS) at first.
I saw the discussions in this thread and made this PR.