Unhandled Exception & Winsock :: Winsock
Hi.
I am working on a winsock program that supports multiple connections simultaneously. For example, the user could connection to more than one server at any given time. The design works, but it fails if the user cancels. In other words, if the user lets the program finish doing work no matter how many connections the user has selected, then the program works. However, if the user cancels via cancel button that sets a status variable in the program to false, then the program begin closing all connections and closing all worker threads.
I am still trying to fingure out what causes the program to crash. Visual C++ outputs this error.
-----
Unhandled exception at 0x77f5111b in myProgram.exe: 0xC0000008: An invalid HANDLE was specified.
-----
Does anyone know what is a good place to start debugging this kind of error? I check all thread handle via WaitForSingleObject() before closing. I use a linked list to store the threads handles.
Thanks,
Kuphryn
Find out the exact line that crashs the app. That''s the first place to start.
What exactly is the status variable? What happens when it''s set to false?
What exactly is the status variable? What happens when it''s set to false?
Stephen ManchesterSenior Technical LeadVirtual Media Vision, Inc.stephen@virtualmediavision.com(310) 930-7349
Okay. Thanks.
I believe I know a place to start debugging the problem now. I think the problem has to do with the fact that if when the user cancels, everything in the program collapse. In other words, the program tries to shutdown everything and I believe each connect tries to shutdown all sockets multiple times.
Maybe the problem is as everything tries to shutdown the sockets and worker threads, somewhere there is there is an invalid thread.
Weird!
Kuphryn
I believe I know a place to start debugging the problem now. I think the problem has to do with the fact that if when the user cancels, everything in the program collapse. In other words, the program tries to shutdown everything and I believe each connect tries to shutdown all sockets multiple times.
Maybe the problem is as everything tries to shutdown the sockets and worker threads, somewhere there is there is an invalid thread.
Weird!
Kuphryn
0x00000008 is a double fault. Somewhere when the system is trying to put together an error message, it faults again.
It''s not the kind of error that happens often. It could be a thread is closed down before winsock is and winsock is trying to report an error to that thread. Only you can find out.
It''s not the kind of error that happens often. It could be a thread is closed down before winsock is and winsock is trying to report an error to that thread. Only you can find out.
Stephen ManchesterSenior Technical LeadVirtual Media Vision, Inc.stephen@virtualmediavision.com(310) 930-7349
Okay. Thanks everyone. I know the problem and has implemented a working solution.
smanches was right on the right track about the threads closing simultaneously. I did in fact set all threads to INVALID_HANDLE_VALUE and checked them all using WaitForSingleObject().
The problem has to do with collapsing all sockets and threads as the user cancels a process. A solution I now use is to close each socket which means all their worker threads after their threads ends and sends a messages to main frame for closing. In other words, instead of stepping through all sockets in the linked list and closing them and their worker threads, now the program waits for them to end since I am using a boolean variable to indicate cancelation. This solution works flawlessly.
Kuphryn
smanches was right on the right track about the threads closing simultaneously. I did in fact set all threads to INVALID_HANDLE_VALUE and checked them all using WaitForSingleObject().
The problem has to do with collapsing all sockets and threads as the user cancels a process. A solution I now use is to close each socket which means all their worker threads after their threads ends and sends a messages to main frame for closing. In other words, instead of stepping through all sockets in the linked list and closing them and their worker threads, now the program waits for them to end since I am using a boolean variable to indicate cancelation. This solution works flawlessly.
Kuphryn
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement