|
Hey All,
Hope this is the right group.
I'm trying to find out the behaviour of WaitForSingleObject when the passed in handle is undefined (NULL or freed by another thread). I haven't seen any article that explains the behaviour of the call in this case. The reason I'm asking is I'm trying to track down a random crash in a multi-threaded application that makes it appear that my mutex is being ignored.
Thanks!
Anthony
|
|
|
|
|
anthonym7 wrote: freed by another thread).
Do you mean closed? You don't free handles (in the sense of malloc / free ). If so, MSDN is very clear:
"If this handle is closed while the wait is still pending, the function's behavior is undefined."
|
|
|
|
|
"If this handle is closed while the wait is still pending,
the function's behavior is undefined."
If the handle is NULL, WaitForSingleObject returns WAIT_FAILED and
GetLastError() returns ERROR_INVALID_HANDLE.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I believe that if you call WFSO with an invalid handle, it will return WAIT_FAILED and GetLastError() will return ERROR_INVALID_HANDLE . Have you tested this to see? Try passing in NULL /0 or a arbitrary value like 0xDEADBEEF .
Peace!
-=- James Please rate this message - let me know if I helped or not!<hr></hr> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
As you already have the answers (which are available in the documentation, but we won't mention that ) I will point out that in my experience having to test for closed or invalid handles can be indicative of bad design. Adding conditional code that executes when the error is discovered will most likely result in yet more random unexpected behavior.
led mike
|
|
|
|
|
Thanks for your thoughts... but I guess I deserve some of the snarky comments. I'm trying to boil down a very complex problem into a few sentences and past experience shows that usually doesn't work. Perhaps I should have proofread my question a bit more carefully.
I never suggested anything in my original postings, just wanted your thoughts on what might happen with WFSO since we are seeing in rare situations a case where the mutex is failing. The system is multi-client/multi-threaded. The handles look fine but WFSO is not behaving as expected.
When we find a resolution, and the answer isn't too complex, I'll reply here.
Thanks again.
|
|
|
|
|
I Guess
Very Complex Problems need to be boiled down to a number of simple problema. I've No Idea of your experience, but, as you are using WFSO, you must have at least two threads in your code. Set Watch and Breakpoints. Set Time aside to Design, and Develop in Small Steps, adding a thread at a time. In my experience, WFSO has never misbehaved! (Not even in WIN95). What happens if you pass it a Crapp handle? Don't know, try it, I doubt that it will crash! The returned value may even be different between (versions of)OS. That's where 'default' in the switch to deal with possible results comes in handy.
Regards
Bram van Kampen
|
|
|
|
|
Hi
I am trying to split the header of a list control into multiple sub-header, but not finding a way to do so…
To put in other words…
I have added say 3 columns named col_1, col_2, col_3 in list control. Now I want to split col_2 into say col_2_sub_1 and col_2_sub_2. Whats the way to do so?
Any help would be appreciated.
Regards
Sameer Thakur
|
|
|
|
|
It sounds like you want to make another column but I don't think anyone clearly understands your question.
led mike
|
|
|
|
|
I stand awaiting correction. This is my interpretation of the question.
------------------------- -------------------------
|_______|_______|_______| |_______|_______|_______|
| | | | ------> | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
| | | | | | | | |
I hope I'm wrong - achieving that is going to make getting these pics look right seem like fun
|
|
|
|
|
This is exactly what I am trying to do.
Nice perception I must say
You have any idea to make it work?
Sameer Thakur
|
|
|
|
|
Sameer_Thakur wrote: This is exactly what I am trying to do.
Well since there is no such thing as a "two column column" it just becomes another column right? Or you could do Owner Draw and draw that column however you like, I have no idea if that would satisfy you requirements because you have not stated them.
I probably still don't have a clue what you are asking.
led mike
|
|
|
|
|
Hello everyone,
I am using "Debug --> Attach to a process" to debug a process on my local computer. The process is not started from my VC project, but already run as a Windows service for a while and I want to attach to it to see some of its variables' status or something.
I have the related source codes, symbol files (PDB) and the binary file (running binary, including an exe and several dlls) of the same version.
I opened the project in VC and using Debug --> Attach to attach the process, it is successful -- but the running binary exe and related dynamically loaded DLLs are not run from the VC project (I mean from Debug/Release directory of the VC project).
My problem is when I set break point in some source codes for the dlls (the dlls are dynamically loaded by the exe using LoadLibrary) , there is error message like -- "The breakpoint will not currently be hit. No symbols have been loaded for this document."
Do I need to set some symbols? Anything wrong or check point for this issue?
thanks in advance,
George
|
|
|
|
|
Are the .pdb files in the same folder as the binaries?
Are you attaching to a release build that doesn't have debug info?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark!
1.
What do you mean "attaching to a release build that doesn't have debug info"?
2.
".pdb files in the same folder as the binaries" -- you mean the same folder as the running binaries (exe/dll)?
regards,
George
|
|
|
|
|
George_George wrote: What do you mean "attaching to a release build that doesn't have debug info"?
Release builds typically don't have debug info associated with them.
George_George wrote: you mean the same folder as the running binaries (exe/dll)?
Yes - up-to-date ones.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark!
"Release builds typically don't have debug info associated with them." -- I am confused about what do you mean debug info? Associated PDB file or something else?
regards,
George
|
|
|
|
|
|
Hi Mark,
1.
I want to confirm with you all debug symbol information are all contained in PDB file -- not in binary itself?
2.
What is the differences between /PDB and /Fd? They both specify the PDB file name, differences are?
regards,
George
|
|
|
|
|
Read the docs at the links.
It's the same info I'd give you.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I did not find any links in your post? Which link do you mean?
regards,
George
|
|
|
|
|
George_George wrote: I did not find any links in your post?
Four links here![^]
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks Mark,
The document I need is how debugger will utilize PDB file to resolve symbol names and also how debugger will use PDB to match the value with the related variable names.
I read your recommended documents, but they do not cover this topic. Do you have any documents about this topic to recommend? I did some search, but not find any.
regards,
George
|
|
|
|
|
By reading this description I think the Running Service uses the binary from the different location (Eg : C:\Program Files) and you kept your changes in Debug/Release folder of the project.
You have to replace changed binary at the location from where service initiates. Keep the PDB files related to it in same folder.
Then Start the service and try to debug .
Hope this will work for u....
Best Of luck.
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
Thanks Mahesh,
Does optimization setting in compiler impacts whether I could use PDB/source files opened in VS to attach and debug a running process?
regards,
George
|
|
|
|