Staged changes (1) modified guix/build/syscalls.scm @@ -1139,10 +1139,19 @@ (define %mmap (define %mmap-guardian (make-guardian)) +(define %unmapped-bytevectors + (make-weak-key-hash-table)) + +(define (unmapped-bytevector? bv) + "True if the bytevector BV was already munmap'd." + (hashq-ref %unmapped-bytevectors bv #f)) + (define (pump-mmap-guardian) (let ((bv (%mmap-guardian))) (when bv - (munmap bv) + (if (unmapped-bytevector? bv) + (hashq-remove! %unmapped-bytevectors bv) + (munmap bv)) (pump-mmap-guardian)))) (add-hook! after-gc-hook pump-mmap-guardian) @@ -1180,7 +1189,8 @@ (define (munmap bv) (unless (zero? ret) (throw 'system-error "munmap" "munmap ~S with len ~S: ~A" (list ptr len (strerror err)) - (list err))))) + (list err))) + (hashq-set! %unmapped-bytevectors bv #t))) (define MS_ASYNC 1) ;sync memory asynchronously (define MS_INVALIDATE 2) ;invalidate the caches