fukamachi / lack

Lack, the core of Clack
MIT License
156 stars 33 forks source link

Issue with (lack.util:generate-random-id) #84

Closed nerap528 closed 6 months ago

nerap528 commented 7 months ago

I've deployed an app based on caveman, which has the following builder form:

(builder
 (:static
  :path (lambda (path)
          (if (ppcre:scan "^(?:/img/|/css/|/js/|/bootstrap-icons/|/robot\\.txt$|/favicon\\.ico$)" path)
              path
              nil))
  :root *static-directory*)
 (if (productionp)
     nil
     :accesslog)
 (if (getf (config) :error-log)
     `(:backtrace
       :output ,(getf (config) :error-log))
     nil)
 (:session
  :store (add-redis-store "session"))
 (if (productionp)
     nil
     (lambda (app)
       (lambda (env)
         (let ((datafly:*trace-sql* t))
           (funcall app env)))))
 *web*)

I regularly get the following error message, which breaks the app:

The value
  -1
is not of type
  (UNSIGNED-BYTE 64)
   [Condition of type TYPE-ERROR]

Restarts:
 0: [ABORT] abort thread (#<THREAD tid=177430 "hunchentoot-worker-127.0.0.1:39174" RUNNING {1001239CC3}>)

Backtrace:
  0: (CL-ISAAC:RAND64 #S(CL-ISAAC:ISAAC64-CTX :RANDCNT 0 :RANDRSL #(13215877931045572616 17298049149423105917 5875697471544487805 18220801150169168170 8730969987868738781 17791624900886399436 ...) :RANDMEM..
      Locals:
        CTX = #S(CL-ISAAC:ISAAC64-CTX ..)
  1: (CL-ISAAC:RAND-BITS-64 #S(CL-ISAAC:ISAAC64-CTX :RANDCNT 0 :RANDRSL #(13215877931045572616 17298049149423105917 5875697471544487805 18220801150169168170 8730969987868738781 17791624900886399436 ...) :R..
      Locals:
        CTX = #S(CL-ISAAC:ISAAC64-CTX ..)
        N = 160
  2: (LACK.UTIL:GENERATE-RANDOM-ID)
      [No Locals]
  3: ((LAMBDA (LACK.MIDDLEWARE.SESSION::ENV) :IN "/home/user/.roswell/lisp/quicklisp/dists/quicklisp/software/lack-20231021-git/src/middleware/session.lisp") (:REQUEST-METHOD :GET :SCRIPT-NAME "" :PATH-INF..
      Locals:
        LACK.MIDDLEWARE.SESSION::ENV = (:REQUEST-METHOD :GET :SCRIPT-NAME "" :PATH-INFO "/" ...)
  4: ((LAMBDA (LACK.MIDDLEWARE.BACKTRACE::ENV) :IN "/home/user/.roswell/lisp/quicklisp/dists/quicklisp/software/lack-20231021-git/src/middleware/backtrace.lisp") (:REQUEST-METHOD :GET :SCRIPT-NAME "" :PATH..
      Locals:
        LACK.MIDDLEWARE.BACKTRACE::ENV = (:REQUEST-METHOD :GET :SCRIPT-NAME "" :PATH-INFO "/" ...)
  5: ((:METHOD HUNCHENTOOT:ACCEPTOR-DISPATCH-REQUEST (CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR T)) #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)> #<HUNCHENTOOT:REQUEST {10015100E..
      Locals:
        CLACK.HANDLER.HUNCHENTOOT::ACCEPTOR = #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)>
        CLACK.HANDLER.HUNCHENTOOT::REQ = #<HUNCHENTOOT:REQUEST {10015100E3}>
  6: ((:METHOD HUNCHENTOOT:HANDLE-REQUEST (HUNCHENTOOT:ACCEPTOR HUNCHENTOOT:REQUEST)) #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)> #<HUNCHENTOOT:REQUEST {10015100E3}>) [fast-met..
      Locals:
        SB-C::.ANONYMOUS. = #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)>
        SB-C::.ANONYMOUS.#1 = #<HUNCHENTOOT:REQUEST {10015100E3}>
  7: ((:METHOD HUNCHENTOOT:PROCESS-REQUEST (T)) #<HUNCHENTOOT:REQUEST {10015100E3}>) [fast-method]
      Locals:
        SB-C::.ANONYMOUS. = #<HUNCHENTOOT:REQUEST {10015100E3}>
      Catch-tags:
        HUNCHENTOOT::HANDLER-DONE
        HUNCHENTOOT::REQUEST-PROCESSED
  8: (HUNCHENTOOT::DO-WITH-ACCEPTOR-REQUEST-COUNT-INCREMENTED #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)> #<FUNCTION (LAMBDA NIL :IN HUNCHENTOOT:PROCESS-CONNECTION) {10014AFF9B..
      Locals:
        SB-C::.ANONYMOUS. = #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)>
        FUNCTION = #<FUNCTION (LAMBDA () :IN HUNCHENTOOT:PROCESS-CONNECTION) {10014AFF9B}>
  9: ((:METHOD HUNCHENTOOT:PROCESS-CONNECTION (HUNCHENTOOT:ACCEPTOR T)) #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)> #<USOCKET:STREAM-USOCKET {10012AFA53}>) [fast-method]
      Locals:
        SB-C::.ANONYMOUS. = #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)>
        HUNCHENTOOT::LOCAL = ("127.0.0.1" 5000)
        HUNCHENTOOT::REMOTE = ("127.0.0.1" 39174)
        HUNCHENTOOT::SOCKET = #<USOCKET:STREAM-USOCKET {10012AFA53}>
        HUNCHENTOOT::SOCKET-STREAM = #<SB-SYS:FD-STREAM for "socket 127.0.0.1:5000, peer: 127.0.0.1:39174" {1001239933}>
 10: ((:METHOD HUNCHENTOOT:PROCESS-CONNECTION :AROUND (HUNCHENTOOT:ACCEPTOR T)) #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)> #<USOCKET:STREAM-USOCKET {10012AFA53}>) [fast-method..
      Locals:
        SB-C::.ANONYMOUS. = #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)>
        SB-PCL::.NEXT-METHOD-CALL. = #S(SB-PCL::FAST-METHOD-CALL :FUNCTION #<FUNCTION (SB-PCL::FAST-METHOD HUNCHENTOOT:PROCESS-CONNECTION (HUNCHENTOOT:ACCEPTOR T))> :PV NIL :NEXT-METHOD-CALL NIL :ARG-INFO (2))
        HUNCHENTOOT::SOCKET = #<USOCKET:STREAM-USOCKET {10012AFA53}>
 11: ((:METHOD HUNCHENTOOT:PROCESS-CONNECTION :AROUND (CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR T)) #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)> #<USOCKET:STREAM-USOCKET {10012..
      Locals:
        SB-PCL::.NEXT-METHOD-CALL. = #S(SB-PCL::FAST-METHOD-CALL ..)
        CLACK.HANDLER.HUNCHENTOOT::ACCEPTOR = #<CLACK.HANDLER.HUNCHENTOOT::CLACK-ACCEPTOR (host 127.0.0.1, port 5000)>
        CLACK.HANDLER.HUNCHENTOOT::SOCKET = #<USOCKET:STREAM-USOCKET {10012AFA53}>
 12: ((:METHOD HUNCHENTOOT::HANDLE-INCOMING-CONNECTION% (HUNCHENTOOT:ONE-THREAD-PER-CONNECTION-TASKMASTER T)) #<HUNCHENTOOT:ONE-THREAD-PER-CONNECTION-TASKMASTER {10079B58F3}> #<USOCKET:STREAM-USOCKET {1001..
      Locals:
        HUNCHENTOOT::SOCKET = #<USOCKET:STREAM-USOCKET {10012AFA53}>
        HUNCHENTOOT:TASKMASTER = #<HUNCHENTOOT:ONE-THREAD-PER-CONNECTION-TASKMASTER {10079B58F3}>
 13: ((LABELS BORDEAUX-THREADS::%BINDING-DEFAULT-SPECIALS-WRAPPER :IN BORDEAUX-THREADS::BINDING-DEFAULT-SPECIALS))
      [No Locals]
 14: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
 15: ((FLET "WITHOUT-INTERRUPTS-BODY-" :IN SB-THREAD::RUN))
 16: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
 17: ((FLET "WITHOUT-INTERRUPTS-BODY-" :IN SB-THREAD::RUN))
 18: (SB-THREAD::RUN)
 19: ("foreign function: call_into_lisp_")
 20: ("foreign function: funcall1")
nerap528 commented 7 months ago

There are massive issues with (lack.util:generate-random-id) on Debian (Linux 5.10)

File Edit Options Buffers Tools SLDB Presentations Help
Callback Error: the message-complete callback failed
  #<FLEXI-STREAMS::VECTOR-INPUT-STREAM {100708EEF3}> cannot be printed readably.
   [Condition of type FAST-HTTP.ERROR:CB-MESSAGE-COMPLETE]

Restarts:
 0: [ABORT] abort thread (#<THREAD tid=191236 "clack-handler-woo" RUNNING {1001228003}>)

Backtrace:
  0: (CL-ISAAC:RAND64 #S(CL-ISAAC:ISAAC64-CTX :RANDCNT 0 :RANDRSL #(17836357377385596082 12957892003282610769 1278280854280301195 5452824792191786772 9611507654064445638 12961598231781886226 ...) :RANDMEM ..
  1: (CL-ISAAC:RAND-BITS-64 #S(CL-ISAAC:ISAAC64-CTX :RANDCNT 0 :RANDRSL #(17836357377385596082 12957892003282610769 1278280854280301195 5452824792191786772 9611507654064445638 12961598231781886226 ...) :RA..
  2: (LACK.UTIL:GENERATE-RANDOM-ID)
  3: ((LAMBDA (LACK.MIDDLEWARE.SESSION::ENV) :IN "/home/user/.roswell/lisp/quicklisp/dists/quicklisp/software/lack-20231021-git/src/middleware/session.lisp") (:RAW-BODY #<FLEXI-STREAMS::VECTOR-INPUT-STREAM..
  4: ((LAMBDA (LACK.MIDDLEWARE.BACKTRACE::ENV) :IN "/home/user/.roswell/lisp/quicklisp/dists/quicklisp/software/lack-20231021-git/src/middleware/backtrace.lisp") (:RAW-BODY #<FLEXI-STREAMS::VECTOR-INPUT-ST..
  5: ((LAMBDA NIL :IN WOO::SETUP-PARSER))
  6: ((LAMBDA (FAST-HTTP.HTTP:HTTP) :IN FAST-HTTP:MAKE-PARSER) #<unused argument>)
  7: (FAST-HTTP.PARSER::PARSE-BODY #S(FAST-HTTP.HTTP:HTTP-REQUEST :METHOD :GET :MAJOR-VERSION 1 :MINOR-VERSION 0 :STATUS 0 :CONTENT-LENGTH NIL :CHUNKED-P NIL ...) #<unavailable argument> #<unavailable argu..
  8: (FAST-HTTP.PARSER:PARSE-REQUEST #S(FAST-HTTP.HTTP:HTTP-REQUEST :METHOD :GET :MAJOR-VERSION 1 :MINOR-VERSION 0 :STATUS 0 :CONTENT-LENGTH NIL :CHUNKED-P NIL ...) #S(FAST-HTTP.PARSER:CALLBACKS :MESSAGE-B..
  9: ((LAMBDA (FAST-HTTP::DATA &KEY :START :END) :IN FAST-HTTP:MAKE-PARSER) #(71 69 84 32 47 32 ...) :START #<unavailable argument> :END #<unavailable argument>)
 10: (WOO::READ-CB #S(WOO.EV.SOCKET:SOCKET :WATCHERS #(#<system area pointer: #X7F646C011640> #<system area pointer: #X7F646C001960> #<system area pointer: #X7F646C011600>) :LAST-ACTIVITY 1.714327324311712..
 11: ((LAMBDA (WOO.EV.TCP::EVLOOP WOO.EV.TCP::WATCHER WOO.EV.TCP::EVENTS) :IN "/home/user/.roswell/lisp/quicklisp/dists/quicklisp/software/woo-20231021-git/src/ev/tcp.lisp") #<unused argument> #<system are..
 12: ((LAMBDA (SB-ALIEN::ARGS-POINTER SB-ALIEN::RESULT-POINTER FUNCTION) :IN "/home/user/.roswell/lisp/quicklisp/dists/quicklisp/software/woo-20231021-git/src/ev/socket.lisp") #<unavailable argument> #<una..
 13: ("foreign function: funcall_alien_callback")
 14: ("foreign function: callback_wrapper_trampoline")
 15: ("foreign function: #x5000119C")
 16: (WOO:RUN #<FUNCTION (LAMBDA (LACK.MIDDLEWARE.BACKTRACE::ENV) :IN "/home/user/.roswell/lisp/quicklisp/dists/quicklisp/software/lack-20231021-git/src/middleware/backtrace.lisp") {100730915B}> :DEBUG T :..
 17: ((FLET BORDEAUX-THREADS-2::RUN-FUNCTION :IN BORDEAUX-THREADS-2::ESTABLISH-DYNAMIC-ENV))
 18: ((LABELS BORDEAUX-THREADS-2::%ESTABLISH-DYNAMIC-ENV-WRAPPER :IN BORDEAUX-THREADS-2::ESTABLISH-DYNAMIC-ENV))
 19: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
 20: ((FLET "WITHOUT-INTERRUPTS-BODY-" :IN SB-THREAD::RUN))
 21: ((FLET SB-UNIX::BODY :IN SB-THREAD::RUN))
 22: ((FLET "WITHOUT-INTERRUPTS-BODY-" :IN SB-THREAD::RUN))
 23: (SB-THREAD::RUN)
 24: ("foreign function: call_into_lisp_")
 25: ("foreign function: funcall1")
nerap528 commented 7 months ago

I've fixed the issue by simply using ironclad instead of isaac:rand-bits-64 in util.lisp. (ironclad:byte-array-to-hex-string (ironclad:random-data 20))

fukamachi commented 6 months ago

Same as #81 ?

nerap528 commented 6 months ago

Same as #81 ?

Yes, it's the same issue.

fukamachi commented 6 months ago

Okay, then it should be fixed now. (ref #82)