Hi all,<br><br>On Windows Vista (64-bit on quad-core CPU), MrEd-Designer randomly crashes when working on a large and somewhat complex UI. At the command prompt I get a trace, and the last one included:<br><br>ptr-ref: contract violation<br>
expected: (and/c cpointer? (not/c (lambda (p) (pointer-equal? p #f))))<br> given: #f<br> argument position: 1st<br> other arguments:<br> #<ctype:scheme><br> context:<br> ...\collects\mred\private\wx\win32\wndclass.rkt:43:0: set-hwnd-wx!<br>
...\collects\racket\private\class-internal.rkt:3960:0: continue-make-object<br> ...\collects\mred\private\wx\win32\panel.rkt:16:2<br> ...\collects\racket\private\class-internal.rkt:3960:0: continue-make-object<br> ...\collects\mred\private\wx\win32\panel.rkt:98:2<br>
...\collects\racket\private\class-internal.rkt:3960:0: continue-make-object<br> ...\collects\mred\private\wxwindow.rkt:14:6<br> ...\collects\racket\private\class-internal.rkt:3960:0: continue-make-object<br> ...\collects\mred\private\wxitem.rkt:34:6<br>
...\collects\racket\private\class-internal.rkt:3960:0: continue-make-object<br> ...\collects\mred\private\wxpanel.rkt:69:4<br> ...\collects\racket\private\class-internal.rkt:3960:0: continue-make-object<br> ...\collects\racket\private\class-internal.rkt:3960:0: continue-make-object<br>
...\collects\racket\private\class-internal.rkt:3960:0: continue-make-object<br> ...\collects\racket\private\class-internal.rkt:3960:0: continue-make-object<br> ...\collects\racket\private\class-internal.rkt:3960:0: continue-make-object...<br>
<br>Where wndclass.rkt contains:<br><br>(define (set-hwnd-wx! hwnd wx)<br> (let* ([c (GetWindowLongPtrW hwnd GWLP_USERDATA)]<br> [v (ptr-ref c _racket)])<br> (vector-set! v 0 (make-weak-box wx))))<br><br>and two functions that invoke SetWindowLongPtrW GWLP_USERDATA:<br>
<br>;; call in atomic mode:<br>(define (register-hwnd! hwnd)<br> (hash-set! all-hwnds (cast hwnd _pointer _intptr) #t)<br> (let ([c (malloc-immobile-cell (vector #f #f #f))])<br> (void (SetWindowLongPtrW hwnd GWLP_USERDATA c))))<br>
<br>and:<br><br>;; call in atomic mode:<br>(define (unregister-hwnd! hwnd)<br> (let ([c (GetWindowLongPtrW hwnd GWLP_USERDATA)])<br> (when c<br> (free-immobile-cell c)<br> (SetWindowLongPtrW hwnd GWLP_USERDATA #f))<br>
(hash-remove! all-hwnds (cast hwnd _pointer _intptr))))<br><br>Since the crashes occur at random it seems likely that there is some sort of race condition (perhaps caused by the register and/or unregister functions not being called in 'atomic' mode), but my unfamiliarity with the internals of both MrEd-Designer and the GUI components of Racket leave me at a bit of a loss at how to proceed debugging this problem. Any hints or tips would be very welcome.<br>
<br>Cheers,<br><br>Kieron.<br><br>