cs: fix hashing on vector cycles

This commit is contained in:
Matthew Flatt 2019-01-16 20:50:41 -07:00
parent b5cce5fcab
commit 11f12d69bd
2 changed files with 19 additions and 13 deletions

View File

@ -356,15 +356,21 @@ transcript.
(define non-z void) (define non-z void)
(define (find-depth go) (define (find-depth go)
; Find depth that triggers a stack overflow (assuming no other (cond
; threads are running and overflowing) [(eq? 'racket (system-type 'vm))
(let ([v0 (make-vector 6)] ; Find depth that triggers a stack overflow (assuming no other
[v1 (make-vector 6)]) ; threads are running and overflowing)
(let find-loop ([d 100]) (let ([v0 (make-vector 6)]
(vector-set-performance-stats! v0) [v1 (make-vector 6)])
(go d) (let find-loop ([d 100])
(vector-set-performance-stats! v1) (vector-set-performance-stats! v0)
(if (> (vector-ref v1 5) (go d)
(vector-ref v0 5)) (vector-set-performance-stats! v1)
d (if (> (vector-ref v1 5)
(find-loop (* 2 d)))))) (vector-ref v0 5))
d
(find-loop (* 2 d)))))]
[else
;; No way to detect stack overflow, and it's less interesting anyway,
;; but make up a number for testing purposes
1000]))

View File

@ -122,7 +122,7 @@
(cond (cond
[(fx= i len) (values hc burn)] [(fx= i len) (values hc burn)]
[else [else
(let-values ([(hc0 burn) (equal-hash-loop (vector-ref x i) burn 0)]) (let-values ([(hc0 burn) (equal-hash-loop (vector-ref x i) (fx+ burn 2) 0)])
(vec-loop (fx+ i 1) (vec-loop (fx+ i 1)
burn burn
(+/fx (mix2 hc) hc0)))]))]))] (+/fx (mix2 hc) hc0)))]))]))]