Random crashes on Windows 7

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Random crashes on Windows 7

Michael T.
Hi,
 I've been working on an application for some time.
Recently I've been given a new notebook and installed Windows 7 Proffessional on it.
Moved my MinGW stuff there and continued developing .

In a certain situation I've noticed random crashes. As I don't believe on randomness I tried to find a case, where it would crash repeatedly. I managed to do so and I found out it crashed on a free() function after several particular actions.
Always the same dynamic array variable. I investigated and searched for standard free() crash bugs.
Couldn't find one. So I went on to search for malloc() misuse, array bound bugs (that's why I started a thread on this list on that topic, too).

Today I came across compatibility options for the .exe files (right-click on the icon atc...). I tried Windows Vista, then Windows XP, and guess what, for both options no crashes! I tried my test case and no problem at all, then I switched back to non-compatibility mode and the problem appeared again as it did before.

My question is - why is this thing happening?
It's GTK+ application with latest GTK runtime installed, all GTK+ calls are called from one thread. Another thread is used for data acquisitions from National Instruments hardware card. Their driver and external .dll library is used for this purpose.

If it works with Vista compatibility, which is in my opinion bigger crap than 7, why the heck doesn't it work under plain 7?
As this is an interesting topic because the use of Windows 7 is expected to spread and so will naturally MinGW compiled code for this system what are your ideas? The crashes were connected to the free() function, however the real problem could be anywhere.

Michael

------------------------------------------------------------------------------
Forrester recently released a report on the Return on Investment (ROI) of
Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
within 7 months.  Over 3 million businesses have gone Google with Google Apps:
an online email calendar, and document program that's accessible from your
browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Random crashes on Windows 7

Tor Lillqvist
> My question is - why is this thing happening?

As you said yourself, the crash happens at a free() call, which is a
strong hint that the heap has been corrupted at some point earlier.
You need to check your dynamic memory handling even harder. (If
possible, try to run your code under valgrind on Linux.)

That is doesn't happen when you tweak the compatibility options is
presumably because they affect the internal details of how the C (and
C++) heap is implemented and happen to hide your bug. It could be that
a dynamically allocated block of memory is overwritten by just a
single byte, and when you have tweaked the compatibility options, that
byte happens to go in a place where it doesn't matter.

> It's GTK+ application with latest GTK runtime installed,

Of course, it *is* possible that there is heap corruption in GTK+,
too. But that is perhaps less likely.

--tml

------------------------------------------------------------------------------
Forrester recently released a report on the Return on Investment (ROI) of
Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
within 7 months.  Over 3 million businesses have gone Google with Google Apps:
an online email calendar, and document program that's accessible from your
browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Random crashes on Windows 7

Georgi Petrov
On Wed, Dec 22, 2010 at 9:47 AM, Tor Lillqvist <[hidden email]> wrote:

>> My question is - why is this thing happening?
>
> As you said yourself, the crash happens at a free() call, which is a
> strong hint that the heap has been corrupted at some point earlier.
> You need to check your dynamic memory handling even harder. (If
> possible, try to run your code under valgrind on Linux.)
>
> That is doesn't happen when you tweak the compatibility options is
> presumably because they affect the internal details of how the C (and
> C++) heap is implemented and happen to hide your bug. It could be that
> a dynamically allocated block of memory is overwritten by just a
> single byte, and when you have tweaked the compatibility options, that
> byte happens to go in a place where it doesn't matter.

This is true. As crazy as it sounds, compatibility settings affect the
help management:
http://technet.microsoft.com/en-us/magazine/ff625273.aspx

Please read it, as it may answer your question :)

------------------------------------------------------------------------------
Forrester recently released a report on the Return on Investment (ROI) of
Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
within 7 months.  Over 3 million businesses have gone Google with Google Apps:
an online email calendar, and document program that's accessible from your
browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Random crashes on Windows 7

lrn-2
In reply to this post by Tor Lillqvist
On 22.12.2010 10:47, Tor Lillqvist wrote:
>> My question is - why is this thing happening?
> As you said yourself, the crash happens at a free() call, which is a
> strong hint that the heap has been corrupted at some point earlier.
> You need to check your dynamic memory handling even harder. (If
> possible, try to run your code under valgrind on Linux.)
I often find myself debugging such problems by inserting an extra free()
call in various places between malloc() and the free() call that
triggers the bug, and then observing its results. If this extra free()
call it crashes - re-insert it somewhere closer to malloc(). If it does
not - re-insert it somewhere closer to free(). That way i get closer and
closer to the code that corrupts the heap.
You might also try setting up a watch at the boundaries of the block,
although i've never tried that myself.

------------------------------------------------------------------------------
Forrester recently released a report on the Return on Investment (ROI) of
Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
within 7 months.  Over 3 million businesses have gone Google with Google Apps:
an online email calendar, and document program that's accessible from your
browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Random crashes on Windows 7

Michael T.
In reply to this post by Georgi Petrov
 
> This is true. As crazy as it sounds, compatibility settings affect the
> help management:
> http://technet.microsoft.com/en-us/magazine/ff625273.aspx
>
> Please read it, as it may answer your question :)

I guess you meant heap management, not help management ;).

Thanks a lot for the article. It was nicely written, I didn't know Microsoft produces
good stuff such as this.

There's quite a lot heap stuff in my program. And the first version was ported from Linux by myself with the hopes  that my predecessor who wrote the original code left no bugs.
However, this assumption might be wrong, and I could have also introduced new bugs myself, of course.
I'll try to make mpatrol work with MinGW. If that doesn't help, I'll try to port actual version of the software back to Linux and run it through Valgrind as Tor suggested.
Never used Valgrind before, but never say never. :)

Thanks guys.

> ------------------------------------------------------------------------------
> Forrester recently released a report on the Return on Investment (ROI) of
> Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
> within 7 months.  Over 3 million businesses have gone Google with Google Apps:
> an online email calendar, and document program that's accessible from your
> browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> This list observes the Etiquette found at
> http://www.mingw.org/Mailing_Lists.
> We ask that you be polite and do the same.  Disregard for the list etiquette may
> cause your account to be moderated.
>
> _______________________________________________
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users
> Also: mailto:[hidden email]?subject=unsubscribe
>
>
>

------------------------------------------------------------------------------
Forrester recently released a report on the Return on Investment (ROI) of
Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
within 7 months.  Over 3 million businesses have gone Google with Google Apps:
an online email calendar, and document program that's accessible from your
browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: Random crashes on Windows 7

Tuomo Latto
In reply to this post by Tor Lillqvist
On 22.12.2010 09:47, Tor Lillqvist wrote:
>> My question is - why is this thing happening?
>
> As you said yourself, the crash happens at a free() call, which is a
> strong hint that the heap has been corrupted at some point earlier.
> You need to check your dynamic memory handling even harder. (If
> possible, try to run your code under valgrind on Linux.)

A more amateur-hackish way would be to sprinkle
the code with _heapchk() calls.



--
Tuomo

... Programming is an art form that fights back


------------------------------------------------------------------------------
Forrester recently released a report on the Return on Investment (ROI) of
Google Apps. They found a 300% ROI, 38%-56% cost savings, and break-even
within 7 months.  Over 3 million businesses have gone Google with Google Apps:
an online email calendar, and document program that's accessible from your
browser. Read the Forrester report: http://p.sf.net/sfu/googleapps-sfnew
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe