fukamachi / fast-http

A fast HTTP request/response parser for Common Lisp.
343 stars 37 forks source link

Expectation failed: NIL when parsing response from google.com #9

Closed orthecreedence closed 9 years ago

orthecreedence commented 9 years ago

Hello! I'm building out carrier and I'm getting an error while grabbing some responses from Google:

(as:with-event-loop (:catch-app-errors nil)
  (future-handler-case
    (multiple-future-bind (nil status)
        (carrier:request "http://google.com")
      (format t "status: ~a~%" status))
    (t (e) (format t "err: ~a~%" e))))

This is throwing the error Expectation failed: NIL with backtrace

> Error: Expectation failed: NIL
> While executing: FAST-HTTP.PARSER::PARSE-CHUNKED-BODY, in process listener(1).
> Type :GO to continue, :POP to abort, :R for a list of available restarts.
> If continued: Skip evaluation of (load "c:/htdocs/test/lisp/carrier")
> Type :? for other options.
1 > b
 (2EA9B04) : 0 (PARSE-CHUNKED-BODY #S(FAST-HTTP.HTTP:HTTP-RESPONSE :METHOD NIL :MAJOR-VERSION 1 ...) #S(FAST-HTTP.PARSER:CALLBACKS :MESSAGE-BEGIN #<CCL:COMPILED-LEXICAL-CLOSURE # #x18238496> :URL #<Compiled-function # (Non-Global)  #x181C049E> ...) #(60 33 100 111 99 ...) 0 9204) 1935
 (2EA9B2C) : 1 (PARSE-RESPONSE #S(FAST-HTTP.HTTP:HTTP-RESPONSE :METHOD NIL :MAJOR-VERSION 1 ...) #S(FAST-HTTP.PARSER:CALLBACKS :MESSAGE-BEGIN #<CCL:COMPILED-LEXICAL-CLOSURE # #x18238496> :URL #<Compiled-function # (Non-Global)  #x181C049E> ...) #(60 33 100 111 99 ...) :START 0 :END NIL) 6007
 (2EA9B5C) : 2 (FUNCALL #'#<(:INTERNAL FAST-HTTP:MAKE-PARSER)> #(60 33 100 111 99 ...) :START 0 :END NIL) 783
 (2EA9BA4) : 3 (READ-SOCKET-DATA #<CL-ASYNC:SOCKET #x18238156> #<CCL:COMPILED-LEXICAL-CLOSURE (:INTERNAL CL-ASYNC::TCP-READ-CB) #x1824DB1E> :SOCKET-IS-EVBUFFER NIL) 647
 (2EA9BD0) : 4 (FUNCALL #'#<CFFI-CALLBACKS::|CL-ASYNC::TCP-READ-CB|> 11943762) 295
 (2EA9BE8) : 5 (%PASCAL-FUNCTIONS% 10 11943762) 343
 (2EA9C30) : 6 (EVENT-BASE-DISPATCH #<A Foreign Pointer #x64F410>) 127
 (2EA9C3C) : 7 (START-EVENT-LOOP #<Anonymous Function #x18224D56> :FATAL-CB NIL :LOGGER-CB NIL :DEFAULT-EVENT-CB NIL :CATCH-APP-ERRORS NIL) 2247
 (2EA9CB8) : 8 (CALL-CHECK-REGS CL-ASYNC:START-EVENT-LOOP #<Anonymous Function #x18224D56> :FATAL-CB NIL :LOGGER-CB NIL :DEFAULT-EVENT-CB NIL :CATCH-APP-ERRORS NIL) 247
 (2EA9CD4) : 9 (FUNCALL #'#<(:INTERNAL CCL::WITH-COMPILATION-UNIT-BODY CCL::LOAD-FROM-STREAM)>) 655
 (2EA9D10) : 10 (CALL-WITH-COMPILATION-UNIT #<CCL:COMPILED-LEXICAL-CLOSURE (:INTERNAL CCL::WITH-COMPILATION-UNIT-BODY CCL::LOAD-FROM-STREAM) #x25418FE> :OVERRIDE NIL) 183
 (2EA9D34) : 11 (LOAD-FROM-STREAM #<BASIC-FILE-CHARACTER-INPUT-STREAM ("c:/htdocs/test/lisp/carrier.lisp"/996 UTF-8) #x175FCD06> NIL) 319
 (2EA9D54) : 12 (%LOAD #P"c:/htdocs/test/lisp/carrier.lisp" NIL NIL :ERROR :DEFAULT NIL) 4599
 (2EA9DF8) : 13 (LOAD "c:/htdocs/test/lisp/carrier" :VERBOSE NIL :PRINT NIL :IF-DOES-NOT-EXIST :ERROR :EXTERNAL-FORMAT :DEFAULT :PRESERVE-OPTIMIZATION-SETTINGS NIL) 927
 (2EA9E4C) : 14 (CALL-CHECK-REGS LOAD "c:/htdocs/test/lisp/carrier") 247
 (2EA9E68) : 15 (CHEAP-EVAL (LOAD "c:/htdocs/test/lisp/carrier")) 87
 (2EA9E84) : 16 (FUNCALL #'#<(:INTERNAL CCL::EVAL-STRING CCL::STARTUP-CCL)> "(load \"c:/htdocs/test/lisp/carrier\")") 431
 (2EA9EA8) : 17 (STARTUP-CCL "home:ccl-init") 1423
 (2EA9ED8) : 18 (FUNCALL #'#<(:INTERNAL (CCL:TOPLEVEL-FUNCTION (CCL::LISP-DEVELOPMENT-SYSTEM T)))>) 55
 (2EA9EE8) : 19 (FUNCALL #'#<(:INTERNAL CCL::MAKE-MCL-LISTENER-PROCESS)>) 559
 (2EA9F34) : 20 (RUN-PROCESS-INITIAL-FORM #<TTY-LISTENER listener(1) [Active] #x173437AE> (#<CCL:COMPILED-LEXICAL-CLOSURE # #x173434E6>)) 639
 (2EA9F78) : 21 (FUNCALL #'#<(:INTERNAL (CCL::%PROCESS-PRESET-INTERNAL (CCL:PROCESS)))> #<TTY-LISTENER listener(1) [Active] #x173437AE> (#<CCL:COMPILED-LEXICAL-CLOSURE # #x173434E6>)) 519
 (2EA9FCC) : 22 (FUNCALL #'#<(:INTERNAL CCL::THREAD-MAKE-STARTUP-FUNCTION)>) 255

This is tested with the latest git version if carrier and fast-io, CCL x86_64 (Windows 7, if that matters).

fukamachi commented 9 years ago

Thank you for reporting. It didn't save the mark & state when a large incomplete chunk came. I think the above commits fixed the error.

orthecreedence commented 9 years ago

Seems to work great, thanks!