Changeset 12907


Ignore:
Timestamp:
Oct 5, 2009, 1:46:58 AM (10 years ago)
Author:
rme
Message:

Offer an "allow this write" restart in response to a
write-to-watched-object condition. There's a dangerous flaw here: if
another thread unwatches the object while we're in the handler,
unpleasantness is likely to ensue.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/watchpoints/level-1/x86-trap-support.lisp

    r12904 r12907  
    432432             ((= code 2)
    433433              ;; Write to a watched object.
     434              ;; We somehow need to guard against another thread unwatching
     435              ;; the object out from underneath us.
    434436              (flet ((%int-to-object (i)
    435437                       (rlet ((a :address))
     
    445447                                           :object object)
    446448                                          nil frame-ptr)
     449                      ;; This certainly has the potential to cause amusing
     450                      ;; errors.
     451                      (allow ()
     452                        :report "Allow this write."
     453                        (let ((result nil)
     454                              (ptr (%int-to-ptr
     455                                    (logandc2 addr (1- *host-page-size*)))))
     456                          (with-other-threads-suspended
     457                            (#_mprotect ptr *host-page-size*
     458                                        #$PROT_WRITE)
     459                            (setq result (x86-emulate-write-instruction xp insn addr object))
     460                            (#_mprotect ptr *host-page-size*
     461                                        (logior #$PROT_READ #$PROT_EXEC)))
     462                          (if result
     463                            (setq skip insn-length)
     464                            (error "can't emulate this write"))))
    447465                      (ignore ()
    448466                        :report "Ignore this write."
Note: See TracChangeset for help on using the changeset viewer.