[Ecls-list] Query about changes

Matthew Mondor mm_lists at pulsar-zone.net
Fri Sep 4 15:46:40 UTC 2009


On Wed, 2 Sep 2009 00:09:27 -0400
Matthew Mondor <mm_lists at pulsar-zone.net> wrote:

> When using ECL's own REPL (I do this from within emacs to obtain decent
> line editing) I do see the debugger show up however, so it seems to be
> a swank-specific issue...

Again when using ECL's own REPL I discovered a problem in a threaded
test of mine which swank would transparently hide and cause ECL to
endless loop on:

When mp:with-lock is used, and that within the body the process gets
interrupted (i.e. via mp:process-kill) the unwind-protected
mp:giveup-lock causes an assertion to signal "Attempt to give up
lock ... that is now owned by process ..." and invoke the debugger.

I'm not sure if this is the proper solution, but probably that
mp_current_process() could be exported as (mp:current-process) and that
mp:with-lock could be reimplemented as follows:

(defmacro with-lock ((lock) &body body)
  `(let ((%the-lock ,lock))
     (unwind-protect
          (progn
            (mp::get-lock %the-lock)
            , at body)
       (when (eq (mp::current-process) (mp::lock-holder %the-lock))
         (mp::giveup-lock %the-lock)))))

Another possibility would be to create and export a new function like
(mp:lockedp lock) and use that...

That said, perhaps it still would be a good idea to also export
mp:current-process?

Yet another way would be to ignore-errors in the giveup-lock
unwind-protect form, since the internal function does the check.
Perhaps a bit hackish, yet requires a minimal change:

(defmacro with-lock ((lock) &body body)
  `(let ((%the-lock ,lock))
     (unwind-protect
          (progn
            (mp::get-lock %the-lock)
            , at body)
       (ignore-errors
         (mp::giveup-lock %the-lock)))))

Thanks,
-- 
Matt




More information about the ecl-devel mailing list