From a782a2040863048dadbe581dff0206ac58906ebe Mon Sep 17 00:00:00 2001 From: Common Lisp at Google Date: Tue, 6 Jul 2021 18:33:17 -0700 Subject: [PATCH] test PiperOrigin-RevId: 383325711 --- buffers.lisp | 3 ++- wire-format.lisp | 9 ++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/buffers.lisp b/buffers.lisp index 6b882e52..1473554b 100644 --- a/buffers.lisp +++ b/buffers.lisp @@ -85,7 +85,8 @@ (backpatches (make-word-buffer 10)) ;; When copying a fixed-size wire-level primitive that crosses a block boundary, ;; use the scratchpad first, then copy two subsequences of octets. - (scratchpad (make-array 8 :element-type '(unsigned-byte 8))) + (scratchpad (make-array 8 :element-type '(unsigned-byte 8) + #+ubsan :initial-element #+ubsan 0)) (n-gap-bytes 0 :type fixnum) (target nil) ; the destination of these octets, a STREAM typically ;; The BUFFER can also pretend to be stream by implementing CHAR-OUT diff --git a/wire-format.lisp b/wire-format.lisp index 40f933d1..82b8b606 100644 --- a/wire-format.lisp +++ b/wire-format.lisp @@ -819,9 +819,12 @@ ;; Don't worry about unaligned writes - they're still faster than ;; looping. Todo: featurize for non-x86 and other than SBCL. (if (buffer-ensure-space buffer ,n-bytes) - (let ((index (buffer-index buffer))) - (setf (,accessor (buffer-sap buffer) index) val - (buffer-index buffer) (+ index ,n-bytes)) + (let ((index (buffer-index buffer)) + (block (buffer-block buffer))) + (sb-sys:with-pinned-objects (block) + (setf (,accessor (sb-sys:vector-sap block) index) val + (buffer-index buffer) (+ index ,n-bytes))) + #+ubsan (sb-vm:%unpoison-range block index (buffer-index buffer)) ,n-bytes) (let ((scratchpad (octet-buffer-scratchpad buffer))) (setf (,accessor (sb-sys:vector-sap scratchpad) 0) val)