Re: Strange dll problem



First, note that that is no such thing as a "crash". There are assertion failures, which
tke place at specific lines of code, and there are hardware-detected errors such as access
faults, which take place at specific instructions. In either case, there are callback
traces available, and there are variables that are involved in the error, and those
variables have values. Lacking anything descriptive other than the nonsense word "crash",
it is hard to determine what is going wrong.


On Fri, 20 Feb 2009 08:32:16 -0800 (PST), Mikel <mikel.luri@xxxxxxxxx> wrote:

Hi all,
I have a strange problem with my app and I can't find a solution. I
hope someone can help me.

I'll try to explain all the steps I have gone through, so it will be a
long post. Sorry for that.

I have an MFC application (for internal use in our company), created
with VS2005 SP1 in Windows XP and it had been running OK on both
Windows XP and Windows Vista. But when the last version was released,
it stopped working on Vista. It crashed before even showing the splash
screen.

With a Virtual Machine I tried to track the problem down in Vista, but
it crashed even before calling CMyApp::InitInstance() or even
CMyApp::CMyApp() so I was quite lost.

I then inspected the changes made to the app and found that the
problem was in a library I had added to make some dialogs resizeable.
I removed the library, made the dialogs fixed-sized again and it
worked fine.

Now I had to discover why that library crashed the application. By the
way, that library is just the classes found at:
http://www.codeproject.com/KB/dialog/dynwindow.aspx or
http://www.datamekanix.com/articles/dynwindow/ made into a lib or dll,
depending on some preprocessor definitions. I tried using them in a
dll and a static lib, with no luck. I'll call this library Codex, for
clarity.

Then I remembered we have another app that uses those same classes,
but in another library with many more classes and utils (I'll call it
OldLib), and it was working fine in Vista. Since that older
application was non-Unicode, I thought that maybe it was a problem
with the Unicode build of the Codex library, so I tried a non-Unicode
build of tha app, and right now I don't remember exactly what went
wrong but it wasn't working either.

Then I tried creating a test application, dialog based, and linking it
to the Codex library, but then again, no luck. If it worked in Vista,
it didn't work in XP; if the Unicode version worked, the non-unicode
didn't. Don't ask me exactly what the problem was, because I did many
tests and in some configurations it worked and in some others it
didn't, but I didn't write it down.

Finally, I decided to take the library we are using in the older app
(OldLib) and remove all the classes and files that are not to be part
of the Codex library and test it with a simple dialog based app.

This is where things start to get weird:
If I remove everything but the classes I need, the Unicode build works
(in XP and Vista), but the non-Unicode doesn't. For the non-Unicode
build to work, I have to leave one class, (CSXButton, which you can
find at http://www.codeguru.com/cpp/controls/buttonctrl/article.php/c2057.
It is a CButton derived class).

Well in fact, I have emptied all function bodies except for one
function call (and some declarations and returns) in CSXButton . If I
remove that function call, the non-Unicode build crashes both in XP
and Vista. But if I leave it, it works OK. This is the function call:

HBITMAP bmTemp = (HBITMAP)::CreateMappedBitmap(hInstResource, nID,
IMAGE_BITMAP, &mapColor, bUseMask ? 1 : 0 );
****
And at the point of failure:
what is the value of hInstResource?
what is the vallue of nID
what is the values in mapColor, and where
is it declared?
why is the declaration of mapColor not shown?

I have a problem with the following call, also, and I was wondering if you tell me why it
fails:
sqrt(n);
You have given no useful information.
****

Another strange thing: if I build the library with the call in, then
take it out and build again, it still works. But if I do a rebuild, it
crashes again.

BTW, the crash is an Unhandled exception of type 0xC0000005: Access
Violation
****
And when you run it under the debugger, what is the backtrace?

Given the information you have provided, I deduce you have a bug in your code. My advice
is to fix it.

If you give USEFUL information, there is a chance that we can actually suggest what went
wrong and what you might do to fix it, but the current report is useless.
****

I have tried to find any relation between CSXButton and the rest of
the classes, but I haven't been able to find any. I guess I have
something wrong, maybe in the project settings, or somewhere else, but
I can't find it.

Does any of these make any sense? Anybody has any ideas on how to
solve it or at least where to start looking. I've run out of ideas
already...
****
You haven't been looking very hard. You have apparently ignored all the basic techniques
of debugging. And the reports that show isolated source lines with no information such as
variable declarations, variable values, etc., are meaningless.
joe
****

Thanks in advance

Mikel
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.


Loading