jsonrpc icon indicating copy to clipboard operation
jsonrpc copied to clipboard

when binding to tcp server inside Bordeaux Thread on MacOS QuickLisp gets stuck and server is not bound to port

Open troydm opened this issue 4 years ago • 4 comments

When binding to tcp server inside Bordeaux Thread on MacOS QuickLisp gets stuck and server is not bound to port

Basically what happens is that (ql:quickload "jsonrpc/transport/tcp" :silent t) is called from inside Bordeaux Thread and it gets stuck thus server is not loaded, not sure whenever it's QuickLisp's problem or just bunch of stuff but this happens on MacOS 10.13.3 running SBCL 2.0.11.

From what I understand root cause is find-mode-class in utils.lisp and it's causing Bordeaux Thread to get stuck, I'm still not sure why QuickLisp gets stuck when loading "jsonrpc/transport/tcp" but it causes whole server not to start

I've encountered this issue when trying to run cl-lsp which started as usually however port was not bound and no error messages were printed so it took me some time to debug this issue

Current workaround that I've found is to call (ql:quickload "jsonrpc/transport/tcp" :silent t) from main thread prior to starting a server, but it's an ad-hoc workaround at best that just happens to work

troydm avatar Jan 02 '21 15:01 troydm

further investigation showed that this actually happens on ASDF side, so when jsonrpc tries to loaded "jsonrpc/transport/tcp" package it results in quicklisp calling (asdf:load-system "jsonrpc/transport/tcp" :verbose nil) and this method call gets stuck if it's called from inside bt thread, still not sure what's causing it to get stuck tho

Tested same setup on Linux, running same version of SBCL and everything works fine, it seems like this is MacOS/ASDF/Bordeaux Threads related issue

troydm avatar Jan 03 '21 03:01 troydm

Further investigation revealed by user @MetaYan from #sbcl IRC revealed that this issue is only SBCL 2.0.11 specific and can't be reproduced on SBCL 2.1.0

troydm avatar Jan 04 '21 00:01 troydm

I was able to reproduced it with mac/sbcl/2.0.11. It seems to be possible to avoid this by doing "(swank:create-server)" beforehand. Perhaps it is a socket issue specific to a particular sbcl version?

cxxxr avatar Jan 06 '21 13:01 cxxxr

@cxxxr it's definitely not socket related as it actually hangs when trying to load asdf system when called inside a separate bordeaux thread, not sure how to avoid it without actually calling (ql:quickload "jsonrpc/transport/tcp" :silent t) before spawning separate jsonrpc tcp server thread. also probably calling (swank:create-server) somehow fixes it, not sure, haven't tried it myself

troydm avatar Jan 06 '21 14:01 troydm