From 2ec097a955b399d8442472288ca50a365a1bbc53 Mon Sep 17 00:00:00 2001 From: Robby Findler Date: Mon, 25 Mar 2013 10:48:59 -0500 Subject: [PATCH] fix bug in drracket's online check syntax renaming setup Because of a limitation in our GC tech (and because I have not sorted out how to program around it (which should be possible)) when the "is it safe to rename this variable" check may silently just say "yes" when it really doesn't know the correct answer. It turns out that this was happening on every attempt to rename after the first one (in a given online check syntax run) due to a bug, now fixed in this commit (the "loop" didn't actually loop...) Also, moved the creation of the thread to its own function to make the things it closes over more syntactically apparent. --- .../drracket/private/syncheck/online-comp.rkt | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/collects/drracket/private/syncheck/online-comp.rkt b/collects/drracket/private/syncheck/online-comp.rkt index c3f022ed0b..6a01101702 100644 --- a/collects/drracket/private/syncheck/online-comp.rkt +++ b/collects/drracket/private/syncheck/online-comp.rkt @@ -15,22 +15,10 @@ (init-field src orig-cust) (define trace '()) - (define-values (remote local) (place-channel)) + (define-values (remote-chan local-chan) (place-channel)) (define table (make-hash)) - ;; the hope is that changing the custodian like this - ;; shouldn't leak these threads, but it does seem to - ;; so for now we don't use it - (parameterize (#;[current-custodian orig-cust]) - (thread - (λ () - (with-handlers ((exn:fail? (λ (x) (eprintf "online-comp.rkt: thread failed ~a\n" (exn-message x))))) - (let loop () - (define id/name (place-channel-get local)) - (define id (list-ref id/name 0)) - (define name (list-ref id/name 1)) - (define res ((hash-ref table id) name)) - (place-channel-put local res)))))) + (create-rename-answerer-thread orig-cust local-chan table) (define/override (syncheck:find-source-object stx) (and (equal? src (syntax-source stx)) @@ -60,13 +48,30 @@ (define/override (syncheck:add-id-set to-be-renamed/poss dup-name?) (define id (hash-count table)) (hash-set! table id dup-name?) - (add-to-trace (vector 'syncheck:add-id-set (map cdr to-be-renamed/poss) remote id))) + (add-to-trace (vector 'syncheck:add-id-set (map cdr to-be-renamed/poss) remote-chan id))) (define/public (get-trace) (reverse trace)) (define/private (add-to-trace thing) (set! trace (cons thing trace))) (super-new))) +(define (create-rename-answerer-thread orig-cust local-chan table) + ;; the hope is that changing the custodian like this + ;; shouldn't leak these threads, but it does seem to + ;; so for now we don't use it + (parameterize (#;[current-custodian orig-cust]) + (thread + (λ () + (with-handlers ((exn:fail? (λ (x) (eprintf "online-comp.rkt: thread failed ~a\n" (exn-message x))))) + (let loop () + (define id/name (place-channel-get local-chan)) + (define id (list-ref id/name 0)) + (define name (list-ref id/name 1)) + (define res ((hash-ref table id) name)) + (place-channel-put local-chan res) + (loop)))))) + (void)) + (define (go expanded path the-source orig-cust) (parameterize ([current-max-to-send-at-once 50]) (with-handlers ((exn:fail? (λ (x)