From 5f66fad355da7ec1bd81bf4f582509619e1f7755 Mon Sep 17 00:00:00 2001 From: Ryan Culpepper Date: Sat, 20 Mar 2021 13:54:13 +0100 Subject: [PATCH] db: fix check for recursive lock acquire --- racket/collects/db/private/generic/common.rkt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/racket/collects/db/private/generic/common.rkt b/racket/collects/db/private/generic/common.rkt index cd8588fa75..9f4908bbcb 100644 --- a/racket/collects/db/private/generic/common.rkt +++ b/racket/collects/db/private/generic/common.rkt @@ -133,8 +133,11 @@ (define sema-peek (lock-sema-peek lk)) (let loop () (define result - (cond [enable-break? (sync/enable-break sema-peek (lock-owner lk))] - [else (sync sema-peek (lock-owner lk))])) + (let ([owner (lock-owner lk)]) + (cond [(eq? owner me) + (error 'lock-acquire "attempted to recursively acquire lock")] + [enable-break? (sync/enable-break sema-peek owner)] + [else (sync sema-peek owner)]))) (cond [(eq? result sema-peek) ;; Got past outer stage (start-atomic) @@ -151,9 +154,6 @@ [(eq? result (lock-owner lk)) ;; Thread holding lock is dead #f] - [(eq? result me) - ;; Attempt to recursively acquire lock - (error 'lock-acquire "attempted to recursively acquire lock")] [else ;; Owner was stale => retry ;; This can happen if the thread holding the lock releases