Open fengyd2006 opened 1 year ago
Is it not enough to just move the ffi.gc(htpurl, ffi.C.free)
before self.url
assignment at the end?
Also, not sure what the effect of garbage collecting a struct http_parser_url *
is going to be in that context, that was probably rightly not ffi.gc()
'ed originally ..
Thanks for reporting I will fix this.
Recently I met a segment fault issue ,and finally found that when calling get_url_field in turbo httputils.lua, ffi.gc is called with the wrong paramter.
ffi.gc(htpurl, ffi.C.free)
htpurl is a temporary pointer, which goes out of scope and will eventually be collected. It should be changed toffi.gc(self.http_parser_url, ffi.C.free)
and put it after:self.http_parser_url = ffi.cast("struct http_parser_url *", htpurl)