fukamachi / woo

A fast non-blocking HTTP server on top of libev
http://ultra.wikia.com/wiki/Woo_(kaiju)
MIT License
1.27k stars 96 forks source link

No format control for simple-error #92

Open gibsonf1 opened 3 years ago

gibsonf1 commented 3 years ago

Although I'm running top-level handlers, this simple-error took down the server:

Sep 12 22:08:36 ip-10-0-0-168 trinity[1166]: 47.254.170.208 - [12/Sep/2020:23:08:36 -07:00] "GET /nice%20ports%2C/Tri%6Eity.txt%2ebak HTTP/1.0" 200 2897 "-" "-"
Sep 12 22:08:42 ip-10-0-0-168 trinity[1166]: Unhandled FAST-HTTP.ERROR:CB-MESSAGE-COMPLETE in thread #<SB-THREAD:THREAD "woo-worker" RUNNING
Sep 12 22:08:42 ip-10-0-0-168 trinity[1166]:                                                            {1047C80A13}>:
Sep 12 22:08:42 ip-10-0-0-168 trinity[1166]:   Callback Error: the message-complete callback failed
Sep 12 22:08:42 ip-10-0-0-168 trinity[1166]:   #<error printing a WOO::INVALID-HTTP-VERSION: #<SIMPLE-ERROR "No format-control for ~S" {104B408C13}>>
Sep 12 22:08:42 ip-10-0-0-168 trinity[1166]: Backtrace for: #<SB-THREAD:THREAD "woo-worker" RUNNING {1047C80A13}>

I took a look at woo.lisp and see the code for this here:

(define-condition woo-error (simple-error) ())
(define-condition invalid-http-version (woo-error) ())

Would simply changing woo-error definition to this solve the problem:?

(define-condition woo-error (simple-error)
  ((description :initarg :description)
   (code :initarg :code
         :initform nil))
  (:report (lambda (condition stream)
             (with-slots (description code) condition
               (format stream
                       "~A~:[~;~:* (Code: ~A)~]"
                       description code)))))
ghost commented 3 years ago

I have the same problem

;error on sbcl

debugger invoked on a FAST-HTTP.ERROR:CB-MESSAGE-COMPLETE in thread
#<THREAD "woo-worker" RUNNING {10054C0313}>:
  Callback Error: the message-complete callback failed
(A SIMPLE-ERROR was caught when trying to print *DEBUG-CONDITION* when entering
the debugger. Printing was aborted and the SIMPLE-ERROR was stored in
SB-DEBUG::*NESTED-DEBUG-CONDITION*.)

The current thread is not at the foreground,
SB-THREAD:RELEASE-FOREGROUND has to be called in #<SB-THREAD:THREAD "main thread" RUNNING {1001560253}>
for this thread to enter the debugger.
;error on ccl

> Error: Callback Error: the message-complete callback failed
>          #<error printing INVALID-HTTP-VERSION #x302001FC565D>
> While executing: (:INTERNAL FAST-HTTP.PARSER::PARSE-BODY), in process woo-worker(4).                               

;;;
;;; #<PROCESS woo-worker(4) [Active] #x302001F5DA4D> requires access to Shared Terminal Input                        
;;; Type (:y 4) to yield control to this thread.
;;;
gibsonf1 commented 3 years ago

I'll do a pull request for this

gibsonf1 commented 3 years ago

https://github.com/fukamachi/woo/pull/93

TheJunglePedantic commented 2 years ago

i think maybe throw out the woo errors and use fast-http:invalid-version. the relevant error handling code only deals with fast-http:parsing-error conditions and even when you fix the format control report error for woo:simple-error, the server still crashes.


(import-from :fast-http
             ;;etc...
             :invalid-version)

(defun http-version-keyword (major minor)
  (unless (= major 1)
    (error 'fast-http:invalid-version))

  (case minor
    (1 :HTTP/1.1)
    (0 :HTTP/1.0)
    (otherwise (error 'fast-http:invalid-version))))