Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

END-KERNEL isn't sufficient to avoid a thread-join race #7

Closed
phmarek opened this issue Feb 24, 2024 · 1 comment
Closed

END-KERNEL isn't sufficient to avoid a thread-join race #7

phmarek opened this issue Feb 24, 2024 · 1 comment

Comments

@phmarek
Copy link

phmarek commented Feb 24, 2024

The current implementation of END-KERNEL isn't sufficient - the threads are not necessarily gone when that function returns.

I'm doing something akin to

  (let (...
        (lparallel:*kernel* (lparallel:make-kernel 4)))
    (format t "Loading...~%")
    (lparallel:pmap nil 
                    (lambda (file)
                      (import-file ...))
                    ...)
    (lparallel:end-kernel :wait t))
  (save-lisp-and-die ...)

but that (sometimes) breaks with

debugger invoked on a SB-IMPL::SAVE-WITH-MULTIPLE-THREADS-ERROR in thread
#<THREAD tid=3161136 "main thread" RUNNING {1003848003}>:
  Cannot save core with multiple threads running.

  Interactive thread (of current session):
    #<THREAD tid=3161136 "main thread" RUNNING {1003848003}>

  Other thread:
    #<THREAD "lparallel" FINISHED values: NIL {1069E88B23}>
See also:
  The SBCL Manual, Node "Saving a Core Image"

What does seem to help is to use

    (map 'nil
         #'sb-thread:join-thread
         (lparallel:end-kernel :wait t))))

but I guess that should be done in lparallel proper?!

Thanks!

@sionescu
Copy link
Member

@phmarek Fixed in 0e80147.

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

No branches or pull requests

2 participants