From: Joseph M. Newcomer on 24 Feb 2010 21:22 Yep. The program doesn't do anything when run in release mode, except that the second CloseHandle returns FALSE. joe On Thu, 25 Feb 2010 00:27:48 +0000, David Lowndes <DavidL(a)example.invalid> wrote: >>Not sure what that article confirms. Even in Vista, and back in NT4, I got this behavior. >>Try this simple program: >> >>int _tmain(int argc, _TCHAR* argv[]) >>{ >> HANDLE h = ::CreateEvent(NULL, FALSE, FALSE, NULL); >> ::CloseHandle(h); >> // The call below gives the exception >> // First-chance exception at 0x77a45e4f in CloseHandle.exe: 0xC0000008: An invalid >>handle was specified. >> ::CloseHandle(h); >> return 0; >>} >> >>I ran it in Vista a few minutes ago and the error text you see is a copy-paste from the >>MessageBox. > >Isn't that just something you get running under the debugger though? > >Modify the code - put a MessageBox after the second CloseHandle, and >run it outside the debugger. > >Dave Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
From: Goran on 25 Feb 2010 02:55 On Feb 24, 6:11 pm, Joseph M. Newcomer <newco...(a)flounder.com> wrote: > CloseHandle definitely will, code 0xC0000008 or 0xC0000009 (I forget which), if you try to > close an invalid handle. > > AFAIK, ReadFile, WriteFile and CreateFile can throw exceptions only if you pass an invalid > address into them. Wow, our code here must be good, I've never seen C0000008 coming out of it! (More like, we probably try to close valid, INVALID_HANDLE_VALUE or NULL handles, for whom nothing is thrown). But e.g CloseHandle(123456) indeed breaks down hard on my machine (just tried). But That said, all of the situations you listed are OK in my book. If I pass invalid handle/address, I have a bug already, so I'll actually thank Windows for kindly :-) pointing it out. Goran.
From: Giovanni Dicanio on 25 Feb 2010 04:20 "Joseph M. Newcomer" <newcomer(a)flounder.com> ha scritto nel messaggio news:pknbo55nu0108i6gqolqdq1empjoc4dfhp(a)4ax.com... > Yep. The program doesn't do anything when run in release mode, except > that the second > CloseHandle returns FALSE. And this was the point of the aforementioned article, I think. Giovanni
From: RaG on 4 Mar 2010 08:21 On Feb 25, 2:20 pm, "Giovanni Dicanio" <giovanniDOTdica...(a)REMOVEMEgmail.com> wrote: > "Joseph M. Newcomer" <newco...(a)flounder.com> ha scritto nel messaggionews:pknbo55nu0108i6gqolqdq1empjoc4dfhp(a)4ax.com... > > > Yep. The program doesn't do anything when run in release mode, except > > that the second > > CloseHandle returns FALSE. > > And this was the point of the aforementioned article, I think. > > Giovanni Hi, I am using c dll in a win32 application, so when control comes to fprintf(stderr) of the c dll code it is crashing.. can any one tell why.How to solve this problem
From: Joseph M. Newcomer on 4 Mar 2010 09:32 First, ANY dlll that makes use of fprintf to stderr is irresponsibly written. There is NO CONCEIVABLE REASON to EVER write ANYTHING from a library! This was irresponsible in C-based console apps and it remains irresponsible. I fought against this in 1968 and have fought against it for decades, but people STILL make the same stupid errors. The writer of a library cannot tell how the library is going to be used, and therefore must NOT presume that issuing a message is going to have meaning (I learned this in 1968 when I needed to use a sqrt subroutine and found that it did two irresponsible things: it printed out a message and it exited the program if the argument was negative. This makes no sense, since I was using it in the context of an interactive system, and I had to issue my OWN message and simply stop execution of the program pointing to the line where the error occurred, but not exit the interactive programming system. The original programmer had actually gone out of his way to make it nearly impossible to use his math library because of all the fprintf(stderr) and exit(0) equivalents he'd put in!) It is *supposed* to crash. stderr does not exist. A library that presumes its existence (or even that using it could ever make sense) is badly written. There's little you can do about this except write a function called fprintf that does what you need. Or rewrite the poorly-written DLL. joe On Thu, 4 Mar 2010 05:21:57 -0800 (PST), RaG <b.raghavender(a)gmail.com> wrote: >On Feb 25, 2:20�pm, "Giovanni Dicanio" ><giovanniDOTdica...(a)REMOVEMEgmail.com> wrote: >> "Joseph M. Newcomer" <newco...(a)flounder.com> ha scritto nel messaggionews:pknbo55nu0108i6gqolqdq1empjoc4dfhp(a)4ax.com... >> >> > Yep. �The program doesn't do anything when run in release mode, except >> > that the second >> > CloseHandle returns FALSE. >> >> And this was the point of the aforementioned article, I think. >> >> Giovanni > >Hi, I am using c dll in a win32 application, so when control comes to >fprintf(stderr) of the c dll code it is crashing.. can any one tell >why.How to solve this problem Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: CPropertySheet default border Next: question about mfc42.dll |