WIN32 BUG?
-
Hello. I have found a bug (in Windows maybe) while writting in Win32 API. I have the following code executed:
OPENFILENAME OpenFileName={0}; // Structure for common dialog File/Open TCHAR szFilter[]=__TEXT("Graphs (*.graph)\0*.graph\0All Files(*.*)\0*.*\0\0"); TCHAR szFile[MAX_PATH]; szFile[0] = __TEXT('\0'); OpenFileName.lStructSize = sizeof(OPENFILENAME); OpenFileName.hwndOwner = hwnd; OpenFileName.hInstance = NULL; OpenFileName.lpstrFilter = szFilter; OpenFileName.lpstrCustomFilter = (LPTSTR) NULL; OpenFileName.nMaxCustFilter = 0L; OpenFileName.nFilterIndex = 1L; OpenFileName.lpstrFile = szFile; OpenFileName.nMaxFile = sizeof(szFile)-1; OpenFileName.lpstrFileTitle = NULL; OpenFileName.nMaxFileTitle = 0; OpenFileName.lpstrInitialDir = NULL; OpenFileName.lpstrTitle = NULL; OpenFileName.nFileOffset = 0; OpenFileName.nFileExtension = 0; OpenFileName.lpstrDefExt = TEXT("graph"); // No default extension OpenFileName.lCustData = 0; OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_LONGNAMES; if (GetOpenFileName(&OpenFileName)){ return (CString)OpenFileName.lpstrFile; } return (CString)"";
This, as I hope you know, creates the Windows OpenFile Dialog. When the window appears do the following: 1. Go to the Desktop. 2. Place the cursor above a file (not a link to a file) and wait for the tooltip to appear. Then press Esc to exit. Then execute again the code and do the same thing (on the same file extension). At that point I get a crash in SHELL32.DLL. See the debug output below. I tried that in an other app and I got the same crash. However, same apps do not crash, so I wonder if I am doing sth wrong or if someone knows sth more about this. Loaded 'C:\WINDOWS\system32\xpsp2res.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Ahead\Lib\NeroDigitalExt.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Ahead\Lib\MFC71.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Ahead\Lib\msvcr71.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Ahead\Lib\msvcp71.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Adobe\Acrobat\ActiveX\pdfshell.dll', no matching symbolic information found. Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft -
Hello. I have found a bug (in Windows maybe) while writting in Win32 API. I have the following code executed:
OPENFILENAME OpenFileName={0}; // Structure for common dialog File/Open TCHAR szFilter[]=__TEXT("Graphs (*.graph)\0*.graph\0All Files(*.*)\0*.*\0\0"); TCHAR szFile[MAX_PATH]; szFile[0] = __TEXT('\0'); OpenFileName.lStructSize = sizeof(OPENFILENAME); OpenFileName.hwndOwner = hwnd; OpenFileName.hInstance = NULL; OpenFileName.lpstrFilter = szFilter; OpenFileName.lpstrCustomFilter = (LPTSTR) NULL; OpenFileName.nMaxCustFilter = 0L; OpenFileName.nFilterIndex = 1L; OpenFileName.lpstrFile = szFile; OpenFileName.nMaxFile = sizeof(szFile)-1; OpenFileName.lpstrFileTitle = NULL; OpenFileName.nMaxFileTitle = 0; OpenFileName.lpstrInitialDir = NULL; OpenFileName.lpstrTitle = NULL; OpenFileName.nFileOffset = 0; OpenFileName.nFileExtension = 0; OpenFileName.lpstrDefExt = TEXT("graph"); // No default extension OpenFileName.lCustData = 0; OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_LONGNAMES; if (GetOpenFileName(&OpenFileName)){ return (CString)OpenFileName.lpstrFile; } return (CString)"";
This, as I hope you know, creates the Windows OpenFile Dialog. When the window appears do the following: 1. Go to the Desktop. 2. Place the cursor above a file (not a link to a file) and wait for the tooltip to appear. Then press Esc to exit. Then execute again the code and do the same thing (on the same file extension). At that point I get a crash in SHELL32.DLL. See the debug output below. I tried that in an other app and I got the same crash. However, same apps do not crash, so I wonder if I am doing sth wrong or if someone knows sth more about this. Loaded 'C:\WINDOWS\system32\xpsp2res.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Ahead\Lib\NeroDigitalExt.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Ahead\Lib\MFC71.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Ahead\Lib\msvcr71.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Ahead\Lib\msvcp71.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Adobe\Acrobat\ActiveX\pdfshell.dll', no matching symbolic information found. Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft -
When I say: "Then execute again the code and do the same thing" I mean without closing your app and rerunning.
kostas KEL
-
Hello. I have found a bug (in Windows maybe) while writting in Win32 API. I have the following code executed:
OPENFILENAME OpenFileName={0}; // Structure for common dialog File/Open TCHAR szFilter[]=__TEXT("Graphs (*.graph)\0*.graph\0All Files(*.*)\0*.*\0\0"); TCHAR szFile[MAX_PATH]; szFile[0] = __TEXT('\0'); OpenFileName.lStructSize = sizeof(OPENFILENAME); OpenFileName.hwndOwner = hwnd; OpenFileName.hInstance = NULL; OpenFileName.lpstrFilter = szFilter; OpenFileName.lpstrCustomFilter = (LPTSTR) NULL; OpenFileName.nMaxCustFilter = 0L; OpenFileName.nFilterIndex = 1L; OpenFileName.lpstrFile = szFile; OpenFileName.nMaxFile = sizeof(szFile)-1; OpenFileName.lpstrFileTitle = NULL; OpenFileName.nMaxFileTitle = 0; OpenFileName.lpstrInitialDir = NULL; OpenFileName.lpstrTitle = NULL; OpenFileName.nFileOffset = 0; OpenFileName.nFileExtension = 0; OpenFileName.lpstrDefExt = TEXT("graph"); // No default extension OpenFileName.lCustData = 0; OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_LONGNAMES; if (GetOpenFileName(&OpenFileName)){ return (CString)OpenFileName.lpstrFile; } return (CString)"";
This, as I hope you know, creates the Windows OpenFile Dialog. When the window appears do the following: 1. Go to the Desktop. 2. Place the cursor above a file (not a link to a file) and wait for the tooltip to appear. Then press Esc to exit. Then execute again the code and do the same thing (on the same file extension). At that point I get a crash in SHELL32.DLL. See the debug output below. I tried that in an other app and I got the same crash. However, same apps do not crash, so I wonder if I am doing sth wrong or if someone knows sth more about this. Loaded 'C:\WINDOWS\system32\xpsp2res.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Ahead\Lib\NeroDigitalExt.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Ahead\Lib\MFC71.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Ahead\Lib\msvcr71.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Ahead\Lib\msvcp71.dll', no matching symbolic information found. Loaded 'C:\Program Files\Common Files\Adobe\Acrobat\ActiveX\pdfshell.dll', no matching symbolic information found. Loaded 'C:\WINDOWS\WinSxS\x86_MicrosoftI have no idea how the code relates to the steps to reproduce the crash. I do see a potential problem with unicode builds though: OpenFileName.nMaxFile = sizeof(szFile)-1; should be OpenFileName.nMaxFile = sizeof(szFile) / sizeof(TCHAR) - 1; Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Could u pls explain in detail? also pls explain what the following means? " I tried that in an other app and I got the same crash. However, same apps do not crash, so I wonder if I am doing sth wrong or if someone knows sth more about this."
Ajay
e.g. Try the following: Make a new MFC dialog project and add a button. Add the code I posted above (without the return statement) for the button click event. Click on the button to make the code run once and then follow the described steps (in my first post). Then click the button again (after you close the dialog using "Esc" or "Cancel") and do the same actions once again. Your app will crash when the tooltip (showing the file type size etc...) appears for the second time. And that happens ONLY on the Desktop (you should try to see the tooltip on the Desktop, and on a file NOT a link to a file). I tried the same thing (openning a file etc...) with an other app (that was a Hex editor I use) that was using (I guess) the same code and I had the same crash. However most of my apps on my PC do not crash when I do this (thank GOD). e.g. Internet Explorer, Acrobat reader, WMedia Player etc. I also tried to run the code on other machines and got the same crash (using my app). The only things (dlls loaded by the shell) in common where the SP2 DLL (xpsp2res.dll) and Acrobat (pdfshell.dll) (I think). I don't know if the source of the problem is in one of them. Note that my code is running perfectly in any folder and it fails ONLY on the Desktop! I suspect that this is a bug of the shell, since there is no obvious problem with my code. I use MSVS 6 C++ and I have SP2 installed. I do not use unicode libraries.
kostas KEL
-
I have no idea how the code relates to the steps to reproduce the crash. I do see a potential problem with unicode builds though: OpenFileName.nMaxFile = sizeof(szFile)-1; should be OpenFileName.nMaxFile = sizeof(szFile) / sizeof(TCHAR) - 1; Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Please see my post above too. This is a small part of it: Note that my code is running perfectly in any folder and it fails ONLY on the Desktop! I suspect that this is a bug of the shell, since there is no obvious problem with my code. I use MSVS 6 C++ and I have SP2 installed. I do not use unicode libraries. Thanks.
kostas KEL
-
Please see my post above too. This is a small part of it: Note that my code is running perfectly in any folder and it fails ONLY on the Desktop! I suspect that this is a bug of the shell, since there is no obvious problem with my code. I use MSVS 6 C++ and I have SP2 installed. I do not use unicode libraries. Thanks.
kostas KEL
If you wish you can download my app from here: http://rapidshare.com/files/64329713/PlotLibDemo.rar.html[^] I had no serious problems after the crash, but it's better to save your work before you do the trick. There is a "open file" icon on one of the windows you'll see. Thanks.
kostas KEL
-
If you wish you can download my app from here: http://rapidshare.com/files/64329713/PlotLibDemo.rar.html[^] I had no serious problems after the crash, but it's better to save your work before you do the trick. There is a "open file" icon on one of the windows you'll see. Thanks.
kostas KEL
OK. Someone helped me out! This is the answer : ====================================================== The problem is that the shell is caching column handlers. When the file dialog exits, it calls CoUninitialize, which unloads all the handlers even if there are references outstanding. The next time the file dialog is opened, the shell tries to access a column handler that isn't there any more. Boom! If you manage COM initialisation yourself, you shouldn't run into this problem. -- Jim Barry, MVP (Windows SDK) ======================================================= BUT, why does this happen ONLY on the Desktop? Normally the shell should do the same thing, no matter which folder you are in, shouldn't it ? ======================================================= It's because the desktop folder is cached. Other folders will be released (thus releasing their column handler caches) before the file dialog exits, but the shell caches the desktop folder and so it outlives the file dialog. -- Jim Barry, MVP (Windows SDK)
kostas KEL