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. #1672

Closed varma08420 closed 11 months ago

varma08420 commented 11 months ago

Discussed in https://github.com/uNetworking/uWebSockets/discussions/1671

Originally posted by **varma08420** October 27, 2023 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&&) (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 , 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
varma08420 commented 11 months ago

I have also implemented onAborted along with onData callbacks.

uNetworkingAB commented 11 months ago

uWS is not thread safe, it's written in the manual.

varma08420 commented 11 months ago

i have been running this library on single thread only i have not completely shown the back trace due to lengthy issue. i have uploaded the same in discussions. @uNetworkingAB

Thanks for replying

varma08420 commented 11 months ago

this issue observe only in Linux OS RHEL 8.1 with gcc version 8.4 something on RHEL 7 above same code works fine.