Closed 5ch-cl-thread-882 closed 2 months ago
It looks like this PR is about the same (or at least a similar) bug that was reported in #504 and fixed in https://github.com/Clozure/ccl/commit/35eb25749ebbfce0c73e9f48b0c041512d771d7f
I wish I would have paid attention to this PR three years ago.
Thanks for referring this PR. (I have forgotten about it, too.) As you say, the commit 35eb25749ebbfce0c73e9f48b0c041512d771d7f would also solve the problem I found. Thank you.
By the way, looking at this PR, it seems that I found connect
in make-udp-socket
similar to make-tcp-socket and took the same measures as it.
However, now I think about it, connect
to UDP sockets only determines the default destination, so even if it fails, the FD should not become unusable, unlike TCP. Therefore, does this mean that nothing needs to be done about UDP sockets?
I think that you are right that we should re-examine the udp socket and file socket cases also. I'm working on that in #507.
Ok, thank you. I'll subscribe #507 and comment if I found something.
I merged #507 and I believe the issue you found in this PR is now fixed.
Again, I'm sorry I didn't pay attention to your PR sooner. My poor excuse is that I wasn't working professionally on CCL at the time you made the PR.
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.