-
Notifications
You must be signed in to change notification settings - Fork 37
Closed
Description
While issue not SBCL specific this code is:
(ql:quickload :fast-http)
(ql:quickload :cl-interpol)
(ql:quickload :trivial-utf-8)
(cl-interpol:enable-interpol-syntax)
(defun random-garbage (length)
(let ((chars "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
(garbage (make-string length)))
(dotimes (i length)
(setf (aref garbage i) (aref chars (random (length chars)))))
garbage))
(defun test-memory-leak (iterations)
(loop for i from 0 to iterations do
(let* ((request (list #?"POST / HTTP/1.1\r\n"
#?"Host: www.example.com\r\n"
#?"Content-Type${(random-garbage 1000)}: application/x-www-form-urlencoded\r\n"
#?"Content-Length: 4\r\n"
#?"Connection: close\r\n"
#?"\r\n"
#?"q=42\r\n"))
(http (fast-http:make-http-request :store-body t ))
(parser (fast-http:make-parser http :store-body t :header-callback (lambda (h) (declare (ignore h)) ))))
(loop for req-chunk in request do
(funcall parser (trivial-utf-8:string-to-utf-8-bytes req-chunk))))))
(define-alien-routine print-generation-stats void)
(sb-ext:gc :full t)
(print-generation-stats)
;; MAGIC
(test-memory-leak 200000) ;; maybe you should adapt this constant to your memory settings
Output
Load 1 ASDF system:
fast-http
; Loading "fast-http"
..
(:FAST-HTTP)
* To load "cl-interpol":
Load 1 ASDF system:
cl-interpol
; Loading "cl-interpol"
...
#<ASDF/SYSTEM:SYSTEM "cl-interpol">
(:CL-INTERPOL)
* To load "trivial-utf-8":
Load 1 ASDF system:
trivial-utf-8
; Loading "trivial-utf-8"
(:TRIVIAL-UTF-8)
*
*
RANDOM-GARBAGE
*
TEST-MEMORY-LEAK
*
PRINT-GENERATION-STATS
*
NIL
* Gen StaPg UbSta LaSta LUbSt Boxed Unboxed LB LUB !move Alloc Waste Trig WP GCs Mem-age
0: 0 0 0 0 1 0 0 0 0 0 32768 10737418 0 0 0.0000
1: 0 0 0 0 0 0 0 0 0 0 0 10737418 0 0 0.0000
2: 0 0 0 0 0 0 0 0 0 0 0 10737418 0 0 0.0000
3: 0 0 0 0 0 0 0 0 0 0 0 10737418 0 0 0.0000
4: 0 0 0 0 0 0 0 0 0 0 0 10737418 0 0 0.0000
5: 0 0 0 0 636 357 68 128 6 37547216 1413936 48284634 698 1 0.0000
6: 0 0 0 0 1702 155 0 0 0 60850176 0 2000000 1608 0 0.0000
Total bytes allocated = 98397392
Dynamic-space-size bytes = 1073741824
NIL
*
Heap exhausted during garbage collection: 128 bytes available, 480 requested.
Gen StaPg UbSta LaSta LUbSt Boxed Unboxed LB LUB !move Alloc Waste Trig WP GCs Mem-age
0: 0 0 0 0 0 0 0 0 0 0 0 10737418 0 0 0.0000
1: 0 0 0 0 0 0 0 0 0 0 0 10737418 0 0 0.0000
2: 0 0 0 0 0 0 0 0 0 0 0 10737418 0 0 0.0000
3: 15219 23801 0 0 1350 13413 348 44 0 494612320 1986720 10737418 0 0 0.9943
4: 0 0 0 0 0 0 0 0 0 0 0 10737418 0 0 0.0000
5: 0 0 0 0 636 357 68 128 6 37547216 1413936 48284634 694 1 0.0000
6: 0 0 0 0 1702 155 0 0 0 60850176 0 2000000 1613 0 0.0000
Total bytes allocated = 1068602064
Dynamic-space-size bytes = 1073741824
GC control variables:
*GC-INHIBIT* = true
*GC-PENDING* = true
*STOP-FOR-GC-PENDING* = false
fatal error encountered in SBCL pid 57429(tid 140737353971520):
Heap exhausted, game over.
Welcome to LDB, a low-level debugger for the Lisp runtime environment.
ldb>
PS. funny thing - chunga and its friends do the same mistake.
Metadata
Metadata
Assignees
Labels
No labels