Re: master: Stop finalizer in S-L-A-D only if no other threads exist

Stas Boukarev <[email protected]> Tue, 3 Mar 2026 10:29:51 +0300
Newsgroups gmane.lisp.steel-bank.cvs,gmane.lisp.steel-bank.devel
Message-ID <CAF63=13kZ-6=-g5gHRXTJKuTKp8OaVGMkCbkKNtBWx75_jGOaQ@mail.gmail.com>
Now on freebsd-arm64, this time the error is coming from sace.c:

Can't save image with more than one executing thread
Unhandled SB-IMPL::SAVE-ERROR in thread #<SB-THREAD:THREAD tid=554037
"main thread" RUNNING
                                           {10019A0143}>:
  Could not save core.
See also:
  The SBCL Manual, Node "Saving a Core Image"

Backtrace for: #<SB-THREAD:THREAD tid=554037 "main thread" RUNNING {10019A0143}>
0: (SB-DEBUG::DEBUGGER-DISABLED-HOOK #<SB-IMPL::SAVE-ERROR
{10019E0373}> #<unused argument> :QUIT T)
1: (SB-DEBUG::RUN-HOOK *INVOKE-DEBUGGER-HOOK* #<SB-IMPL::SAVE-ERROR
{10019E0373}>)
2: (INVOKE-DEBUGGER #<SB-IMPL::SAVE-ERROR {10019E0373}>)
3: (ERROR SB-IMPL::SAVE-ERROR)

I can't say what the baseline before was.

On Wed, Feb 18, 2026 at 6:14 AM Stas Boukarev <[email protected]> wrote:
>
> I'm also getting this on linux-arm64-sb-safepoint:
>
> debugger invoked on a SB-IMPL::SAVE-WITH-MULTIPLE-THREADS-ERROR in thread
> #<THREAD tid=818888 "main thread" RUNNING {1002660343}>:
>   Cannot save core with multiple threads running.
>
>   Interactive thread (of current session):
>     #<THREAD tid=818888 "main thread" RUNNING {1002660343}>
>
>   Other thread:
>     #<THREAD tid=818889 "sigwait" RUNNING {1002660283}>
>
> On Tue, Feb 17, 2026 at 7:14 PM Stas Boukarev <[email protected]> wrote:
> >
> > And it's not limited to windows, the same error can be observed anywhere.
> >
> > On Tue, Feb 17, 2026 at 7:12 PM Stas Boukarev <[email protected]> wrote:
> > >
> > > On windows save7 fails with:
> > > (and after adding
> > >  (format t "~a ~a ~a~%" threads starting joinable))
> > >
> > > (#<THREAD tid=4240 "main thread" RUNNING {10020B0003}>) (#<THREAD
> > > tid=0 "finalizer" RUNNING {1002060363}>) NIL
> > > Unhandled SB-IMPL::SAVE-WITH-MULTIPLE-THREADS-ERROR in thread
> > > #<SB-THREAD:THREAD tid=4240 "main thread" RUNNING
> > >                                                                  {10020B0003}>:
> > >   Cannot save core with multiple threads running.
> > >
> > >   Interactive thread (of current session):
> > >     #<THREAD tid=4240 "main thread" RUNNING {10020B0003}>
> > >
> > >   Other thread:
> > >     0
> > >
> > > On Tue, Feb 17, 2026 at 6:11 PM snuglas via Sbcl-commits
> > > <[email protected]> wrote:
> > > >
> > > > The branch "master" has been updated in SBCL:
> > > >        via  55c0f2e12ab0bc9d1b11a50f4c9d20162740ba83 (commit)
> > > >       from  49044888b298a1ace613a918cdbd4b6ad5bfd586 (commit)
> > > >
> > > > - Log -----------------------------------------------------------------
> > > > commit 55c0f2e12ab0bc9d1b11a50f4c9d20162740ba83
> > > > Author: Douglas Katzman <[email protected]>
> > > > Date:   Tue Feb 17 10:10:56 2026 -0500
> > > >
> > > >     Stop finalizer in S-L-A-D only if no other threads exist
> > > > ---
> > > >  src/code/save.lisp     | 16 ++++++++--------
> > > >  tests/save.impure.lisp | 11 +++++++++++
> > > >  2 files changed, 19 insertions(+), 8 deletions(-)
> > > >
> > > > diff --git a/src/code/save.lisp b/src/code/save.lisp
> > > > index 8db5f7e4a..977a3da5f 100644
> > > > --- a/src/code/save.lisp
> > > > +++ b/src/code/save.lisp
> > > > @@ -324,20 +324,20 @@ sufficiently motivated to do lengthy fixes."
> > > >    #+sb-thread
> > > >    (let (error)
> > > >      (with-system-mutex (sb-thread::*make-thread-lock*)
> > > > -      (finalizer-thread-stop)
> > > >        (sb-thread::%dispose-thread-structs)
> > > >        (let ((threads (sb-thread:list-all-threads))
> > > >              (starting
> > > >               (setq sb-thread::*starting-threads* ; ordinarily pruned in MAKE-THREAD
> > > >                     (delete 0 sb-thread::*starting-threads*)))
> > > >              (joinable sb-thread::*joinable-threads*))
> > > > -        (when (or (cdr threads) starting joinable)
> > > > -          (let* ((interactive (sb-thread::interactive-threads))
> > > > -                 (other (union (set-difference threads interactive)
> > > > -                               (union starting joinable))))
> > > > -            (setf error (make-condition 'save-with-multiple-threads-error
> > > > -                                        :interactive-threads interactive
> > > > -                                        :other-threads other))))))
> > > > +        (if (or (cdr threads) starting joinable)
> > > > +            (let* ((interactive (sb-thread::interactive-threads))
> > > > +                   (other (union (set-difference threads interactive)
> > > > +                                 (union starting joinable))))
> > > > +              (setf error (make-condition 'save-with-multiple-threads-error
> > > > +                                          :interactive-threads interactive
> > > > +                                          :other-threads other)))
> > > > +            (finalizer-thread-stop))))
> > > >      (when error (error error))
> > > >      #+allocator-metrics (setq sb-thread::*allocator-metrics* nil)
> > > >      (setq sb-thread::*sprof-data* nil))
> > > > diff --git a/tests/save.impure.lisp b/tests/save.impure.lisp
> > > > index 364451ce6..1635e31be 100644
> > > > --- a/tests/save.impure.lisp
> > > > +++ b/tests/save.impure.lisp
> > > > @@ -27,3 +27,14 @@
> > > >        (setf donep t)
> > > >        (sb-thread:condition-notify cvar))
> > > >      (sb-thread:join-thread thread)))
> > > > +
> > > > +(with-test (:name (sb-ext:save-lisp-and-die error :multiple-threads-2))
> > > > +  (let* ((sem (sb-thread:make-semaphore))
> > > > +         (thread (sb-thread:make-thread
> > > > +                  (lambda () (sb-thread:wait-on-semaphore sem)))))
> > > > +    (assert (eq (handler-case (save-lisp-and-die "expect_failure")
> > > > +                  (sb-impl::save-with-multiple-threads-error () 'ok))
> > > > +                'ok))
> > > > +    (assert (sb-thread::thread-p sb-impl::*finalizer-thread*))
> > > > +    (sb-thread:signal-semaphore sem)
> > > > +    (sb-thread:join-thread thread)))
> > > >
> > > > -----------------------------------------------------------------------
> > > >
> > > >
> > > > hooks/post-receive
> > > > --
> > > > SBCL
> > > >
> > > >
> > > > _______________________________________________
> > > > Sbcl-commits mailing list
> > > > [email protected]
> > > > https://lists.sourceforge.net/lists/listinfo/sbcl-commits


_______________________________________________
Sbcl-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sbcl-commits