1.0.33.11: fix detection of tls exhaustion
authorGabor Melis <mega@hotpop.com>
Tue, 15 Dec 2009 15:22:22 +0000 (15:22 +0000)
committerGabor Melis <mega@hotpop.com>
Tue, 15 Dec 2009 15:22:22 +0000 (15:22 +0000)
... that was added in 1.0.16.21 and whose ways were shown to be wrong
by the additional pseudo atomic asserts added later.

With this fix the user gets to see the tls exhausted message instead
of a random complaint about pa.

src/assembly/x86-64/alloc.lisp
src/assembly/x86/alloc.lisp
src/compiler/x86-64/macros.lisp
src/compiler/x86/macros.lisp
version.lisp-expr

index 2c113b0..80d5406 100644 (file)
@@ -94,7 +94,8 @@
                (emit-label get-tls-index-lock)
                (inst mov target 1)
                (zeroize rax-tn)
-               (inst cmpxchg (make-ea-for-symbol-value *tls-index-lock*) target :lock)
+               (inst cmpxchg (make-ea-for-symbol-value *tls-index-lock*)
+                     target :lock)
                (inst jmp :ne get-tls-index-lock)
                ;; The symbol is now in OTHER.
                (inst pop other)
                (inst jmp :ne release-tls-index-lock)
                ;; Allocate a new tls-index.
                (load-symbol-value target *free-tls-index*)
-               (let ((error (generate-error-code nil 'tls-exhausted-error)))
+               (let ((not-error (gen-label))
+                     (error (generate-error-code nil 'tls-exhausted-error)))
                  (inst cmp target (fixnumize tls-size))
-                 (inst jmp :ge error))
+                 (inst jmp :l not-error)
+                 (%clear-pseudo-atomic)
+                 (inst jmp error)
+                 (emit-label not-error))
                (inst add (make-ea-for-symbol-value *free-tls-index*)
                      (fixnumize 1))
                (storew target other symbol-tls-index-slot other-pointer-lowtag)
index 65cfdb0..897855b 100644 (file)
                (emit-label get-tls-index-lock)
                (inst mov target 1)
                (inst xor eax-tn eax-tn)
-               (inst cmpxchg (make-ea-for-symbol-value *tls-index-lock*) target :lock)
+               (inst cmpxchg (make-ea-for-symbol-value *tls-index-lock*)
+                     target :lock)
                (inst jmp :ne get-tls-index-lock)
                ;; The symbol is now in OTHER.
                (inst pop other)
                (inst jmp :ne release-tls-index-lock)
                ;; Allocate a new tls-index.
                (load-symbol-value target *free-tls-index*)
-               (let ((error (generate-error-code nil 'tls-exhausted-error)))
+               (let ((not-error (gen-label))
+                     (error (generate-error-code nil 'tls-exhausted-error)))
                  (inst cmp target (fixnumize tls-size))
-                 (inst jmp :ge error))
+                 (inst jmp :l not-error)
+                 (%clear-pseudo-atomic)
+                 (inst jmp error)
+                 (emit-label not-error))
                (inst add (make-ea-for-symbol-value *free-tls-index*)
                      (fixnumize 1))
                (storew target other symbol-tls-index-slot other-pointer-lowtag)
index 018b43c..e591b24 100644 (file)
        (progn ,@body)
        (pseudo-atomic ,@body)))
 
+;;; Unsafely clear pa flags so that the image can properly lose in a
+;;; pa section.
+#!+sb-thread
+(defmacro %clear-pseudo-atomic ()
+  '(inst mov (make-ea :qword :base thread-base-tn
+              :disp (* 8 thread-pseudo-atomic-bits-slot))
+    0))
+
 #!+sb-thread
 (defmacro pseudo-atomic (&rest forms)
   (with-unique-names (label)
index 29d3009..af6f52d 100644 (file)
        (progn ,@forms)
        (pseudo-atomic ,@forms)))
 
+;;; Unsafely clear pa flags so that the image can properly lose in a
+;;; pa section.
+#!+sb-thread
+(defmacro %clear-pseudo-atomic ()
+  '(inst mov (make-ea :dword :disp (* 4 thread-pseudo-atomic-bits-slot)) 0 :fs))
+
 #!+sb-thread
 (defmacro pseudo-atomic (&rest forms)
   (with-unique-names (label)
index 18f2b3f..766a544 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.33.10"
+"1.0.33.11"