[plt-scheme] threads, breaks, and races

From: Dimitris Vyzovitis (vyzo at media.mit.edu)
Date: Sat Jun 30 03:14:52 EDT 2007

On Sat, 30 Jun 2007, Dimitris Vyzovitis wrote:

> > (let ((thr (thread (lambda ()
>                      (with-handlers ((void void))
>                        (sync never-evt))))))
>   (break-thread thr)
>   (thread-dead? thr))
> #f
> > user break
>
> Now, if I add a sleep before breaking the thread, the break is delivered
> normally:
>
> > (let ((thr (thread (lambda ()
>                      (with-handlers ((void void))
>                        (sync never-evt) 'boo)))))
>   (sleep 1)
>   (break-thread thr)
>   (sleep 1)
>   (thread-dead? thr))
> #t
> >

Some more:
> (define thr (thread (lambda ()
                 (with-handlers ((void void))
                   (sync/enable-break never-evt)))))
  (break-thread thr)
> > user break
(thread-dead? thr)
#t

So the race seems to be with installing the exception handler. Not sure I
should call this a bug -- an unpleasant surprise rather...

-- vyzo



Posted on the users mailing list.