[SOLVED] Finding cause of a crashing application
Posted: Wed Feb 01, 2023 2:29 pm
Hi all, I'm looking to find out if OnErrorCall() can help trap an elusive crash. A little background first. I have a server-side application communicating via SendNetworkString() and ReceiveNetworkData() with client-side processes. The server sends data to the client within threads, then ends when the data is sent. It works reliably and quickly except for one aspect. When stress-testing, mid-way through continuous output of a long data stream, sent from server to client, I close the client-side abruptly, to simulate a user ending the process in this way. I can see that the server process recognises this, because it triggers a #PB_NetworkEvent_Disconnect.
Despite this, it sometimes causes the server-side to crash. I use a proper method of checking the number of bytes sent, delaying and re-sending, shown in the line of code below. If further data cannot be sent from the server to the client, then I stop sending data and instead end the thread gracefully. The mechanism used for this is at viewtopic.php?p=328229#p328229
As you may have noticed, my method of stopping the sending of data to the client, is not triggered by #PB_NetworkEvent_Disconnect, because the sending of data is performed inside a separate thread, which doesn't check for that condition. Instead, the thread triggers on timeout, and stops sending further data.
The crash never happens when the debugger is being used, making it difficult for me to find the cause. It also doesn't appear to happen if I add a 1ms delay to the sending of data segments, but when I compile the server-side code and run it normally, then I sometimes see this problem. I see only the following.
"A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available."
Should I be able to make use of OnErrorCall(@ErrorHandler()) that I saw on the forum a few days ago? Looking at the documentation, I'm not sure what kind of error it is intended to trap, as it only says "Changes the action taken if an error occurs ". Is it referring to this type of crash? Any suggestions appreciated.
Despite this, it sometimes causes the server-side to crash. I use a proper method of checking the number of bytes sent, delaying and re-sending, shown in the line of code below. If further data cannot be sent from the server to the client, then I stop sending data and instead end the thread gracefully. The mechanism used for this is at viewtopic.php?p=328229#p328229
Code: Select all
result.i = SendNetworkString(clientid.i, senddata.s, #PB_Unicode)
The crash never happens when the debugger is being used, making it difficult for me to find the cause. It also doesn't appear to happen if I add a 1ms delay to the sending of data segments, but when I compile the server-side code and run it normally, then I sometimes see this problem. I see only the following.
"A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available."
Should I be able to make use of OnErrorCall(@ErrorHandler()) that I saw on the forum a few days ago? Looking at the documentation, I'm not sure what kind of error it is intended to trap, as it only says "Changes the action taken if an error occurs ". Is it referring to this type of crash? Any suggestions appreciated.