uNetworking / uWebSockets

Simple, secure & standards compliant web server for the most demanding of applications
Apache License 2.0
17.29k stars 1.75k forks source link

httpcontext pointer is getting null whcih is causing crash. #1670

Closed varma08420 closed 11 months ago

varma08420 commented 11 months ago

I have compiled all your examples from uSockets and ran all types of routes, which works perfectly fine.i have implemented almost same simple form of http server using App. i observed that for cases in which http body is received , in those cases while responding after processing the data, my application getting crashed at

0 0x00000000004e9ed3 in us_socket_context_loop (ssl=1, context=0x0) at src/context.c:134

1 0x000000000047cbdc in uWS::AsyncSocket::getLoopData (this=0x7f13037ef770)

at /data1/myhome/mahendrae/sib/SIB/genesys/GENESYS/genesysPF//third_party/uWS/include/AsyncSocket.h:86

2 0x000000000047c26e in uWS::AsyncSocket::isCorked (this=0x7f13037ef770)

at /data1/myhome/mahendrae/sib/SIB/genesys/GENESYS/genesysPF//third_party/uWS/include/AsyncSocket.h:151

3 0x000000000047ac6a in uWS::HttpResponse::cork(ofats::any_invocable<void ()>&&) (this=0x7f13037ef770, handler=...)

at /data1/myhome/mahendrae/sib/SIB/genesys/GENESYS/genesysPF//third_party/uWS/include/HttpResponse.h:498

4 0x000000000047358c in RtLIX1Handler::rtSendRespToLim (this=0x2e83590, a_li_resp_data=..., ap_resp=0x7f13037ef770, ap_db_op_data=0x7f12e0090a30,

a_target_vector=std::vector of length 0, capacity 0)
at /data1/myhome/mahendrae/sib/SIB/APP/app_logic/code/LI/RtLIX1Handler/src/RtLIX1Handler.cpp:2488

5 0x000000000047761f in RtLIX1Handler::rtHandleFileDumpResponse (this=0x2e83590, ap_resp_data=0x7f13037df710)

at /data1/myhome/mahendrae/sib/SIB/APP/app_logic/code/LI/RtLIX1Handler/src/RtLIX1Handler.cpp:3588

6 0x000000000046d5ed in RtLIX1Handler::rtHandleTransactionRequest (this=0x2e83590, ap_http_req_data=0x7f13037ed320)

at /data1/myhome/mahendrae/sib/SIB/APP/app_logic/code/LI/RtLIX1Handler/src/RtLIX1Handler.cpp:1288

7 0x0000000000480490 in RtLIHttpHandler::rtSendDataToWrkr (this=0x2e96330, ap_res=0x7f13037ef770,

ap_rest_req_data=0x7eefc0 <RtLIHttpHandler::m_rest_req_data>, a_data_size=355)
at /data1/myhome/mahendrae/sib/SIB/APP/app_logic/code/LI/RtLIHttpHandler/src/RtLIHttpHandler.cpp:627

i have been using single thread to receiving and responding back. i tried to run above case with ASAN to pin point the reason but it runs perfectly fine with asan compiled lib/bin. which made me clue less. from code i observed that when write function gets called context is retrived which returned as null. I have also used res->cork and in lamda i tried to write response back to client. i can also provide any futhure info if you require. i have used latest version 20.46. And also i observed that when i dont send body in cases where onData handler implemented then res pointer gets null by the time i respond back is this behavior expected??!!

Thanks

uNetworkingAB commented 11 months ago

You need to use onAborted and make sure you don't touch the HttpResponse after aborted