-
August 11th, 2004, 05:08 AM
#1
Problem with Pipes in Release mode
I am on XP and I have created an overlapped mode pipe. I call ConnectNamedPipe and set the event on wait in WaitForSingleObject. Problem comes when the WaitForSingleObject times out in release mode compile. Any other call to the pipe handle on which no client connects and connection time out throws some exception in release mode . It all works fine in debug mode.
Code:
OVERLAPPED op;
op.hEvent = CreateEvent(....
HANDLE hPipe = ConnectNamedPipe(....
switch(WaitForSingleObject(op.hEvent, 5000)
{
case WAIT_OBJECT_0:
... // all works fine
CloseHandle(hPipe); // also works fine
case WAIT_TIMOUT:
... // any call to hPipe throws unhandled exception
CloseHandle(hPipe); // throws unhandled exception
}
PS: every thing works fine in Debug mode...Exceptions come in on release mode :sigh:
Atif
-
August 11th, 2004, 06:15 AM
#2
Welll...what does 'ConnectNamedPipe()' return? What error code?
-
August 11th, 2004, 06:18 AM
#3
Originally Posted by atif_husain
PS: every thing works fine in Debug mode...Exceptions come in on release mode :sigh:
What kind of event is thrown? Have you tried debugging the release build?
-
August 12th, 2004, 01:55 AM
#4
Re: Problem with pipes in release mode
Thanks for your response.
As I mentioned in my post that the handle of the pipe returned from the CreateNamePipe call is valid. I can assure you that because it all works fine when a client connects and WaitForSingleObject returns WAIT_OBJECT_0.
But in the case the client does not connect and the WaitForSingleObject returns WAIT_TIMEOUT and I give a call to DisconnectClient and/or Close an exception in raised.
I have tried to catch the exception in CException catch block and C 'exception' block but no luck. I catch it in catch(...) block.
Again this only happens in release mode. I am tracing by writing log in a file.
Thanks and please help me...
Atif
-
August 12th, 2004, 02:07 AM
#5
Originally Posted by atif_husain
Again this only happens in release mode.
I'll ask again - have you already tried debugging the release build? And which type of exception is thrown? Also, what do you mean by "C exception block"? C has no exceptions. Is this a C++ exception, or a Win32 SEH exception? What is the exact message you are getting?
-
August 12th, 2004, 06:23 AM
#6
To ask more clearly...are you having an access violation?
-
August 13th, 2004, 02:04 AM
#7
Actaully I am on XP so I get 'MyProgram has encountered a problem and need to shut down...' The technical information shows this....
Exception Information
Code: 0xc0000005 Flags: 0x00000000
which I think is Access Violation due to unhandled exception.
As for the return handle value of ConnectNamedPipe it is a number and the handle number remains same even after WaitForSingleObject times out.
As for debugging as I mentioned I write a trace log in a txt file in every call after every statement. That is how I got to know where the problem occurs.
The exception at present I catch in a catch(...) handler. I tried catch
catch(CException *exp) and catch(exception *exp) but both did not work. What handler to write for a Win32 SEH exception?
Again I appretiate all the help you are providing......
-
August 13th, 2004, 03:12 AM
#8
All too common, you are writing/reading to some memory you should not be. Many a times it does not shows up debug builds, but the problem is there it debug builds also. It does not shows up because of differences in the way the pointers may be initialised, un initialsed data is filled with pre determined values and such.
Use the debugger to find the problem. Use a map file to find the problem.
Paste the exact code as you have.
Say no to supplying ready made code for homework/work assignments!!
Please rate this post!
-
August 13th, 2004, 03:30 AM
#9
Originally Posted by atif_husain
Exception Information
Code: 0xc0000005 Flags: 0x00000000
which I think is Access Violation due to unhandled exception.
Yes, that's an access violation - not due to unhandled exception, but due to an invalid pointer operation. The exception is a consequence of that, and you can't handle SEH exceptions with C++ try/catch blocks. Besides that, an access violation is a serious bug in your code which should be fixed.
Originally Posted by atif_husain
As for debugging as I mentioned I write a trace log in a txt file in every call after every statement. That is how I got to know where the problem occurs.
But why don't you run your code in the debugger? This will tell you in much more detail why and how the problem occurs. Besides that, it's easier and faster than writing trace logs.
-
August 13th, 2004, 04:43 AM
#10
-
August 13th, 2004, 04:59 AM
#11
-
August 13th, 2004, 06:23 AM
#12
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|