Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C++ Libraries / November 2005

Tip: Looking for answers? Try searching our database.

malloc() & page boundaries -- Difference between VC6 and VC7 CRT?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew - 23 Nov 2005 06:06 GMT
I was wondering if anyone knew of any changes in the CRT that would cause
malloc behavior to change between code built with VC6/VC7? We discovered a
segfault bug in production code built with VC6 that was not crashing
frequently at all. We fixed the bug, but in the meantime, our builds were in
the process of being switched to VC7. In the VC7 built code, the same crash
occurs much more frequently. This alarmed us, so we are investigating why VC7
behavior would differ so much from VC6.

The nature of the bug is such that many small buffers (~16 bytes) are being
malloc'd but the bug causes the code to read past the end of the buffer by 8
bytes. Straightforward, and this crashes whenever the address to the 17th
byte lives on the next memory page which happens to not be allocated.

The issue is in VC6 built code, this bug rarely occurs, almost as if the
memory allocation never allocates that close to an invalid page, or never
completely
fills up an entire page. When the code is built in VC7, the crash occurs
very, very frequently, as if the 16 bytes are being allocated at the end of
the
page prior to an invalid one.

My question is if anything regarding malloc or the heap changed between
VC6/VC7 that could be behind this. Do any of the compiler optimization flags
affect malloc's ability to alloc up to the last available byte in a page?

We have discovered the source of the bug in remote code and have fixed it,
but we are questioning if it is safe to move to VC7 so quickly.
David Lowndes - 23 Nov 2005 13:49 GMT
>I was wondering if anyone knew of any changes in the CRT that would cause
>malloc behavior to change between code built with VC6/VC7?

I don't know the details, but I do recall comments that it was changed
significantly, so that may well account for the differences you see.

>We have discovered the source of the bug in remote code and have fixed it,
>but we are questioning if it is safe to move to VC7 so quickly.

Quickly!

VC8 is out now you know ;)

Dave
Signature

MVP VC++ FAQ: http://www.mvps.org/vcfaq

Ale Contenti [MSFT] - 28 Nov 2005 18:56 GMT
I would argue that it is much "safer" to move to VC7 (or VC8), because you were able to track down a dangerous "buffer overrun" problem, and make your app more robust and secure.

Am I wrong?

About the malloc changes, very likely this is caused by the changes in the small block allocator, like Daniel pointed out on microsoft.public.vc.language.

Thanks!

Ale Contenti
VC++ Libraries

-----Original Message-----
From: David Lowndes
Posted At: Wednesday, November 23, 2005 5:49 AM
Posted To: microsoft.public.dotnet.languages.vc.libraries
Conversation: malloc() & page boundaries -- Difference between VC6 and VC7 CRT?
Subject: Re: malloc() & page boundaries -- Difference between VC6 and VC7 CRT?

>I was wondering if anyone knew of any changes in the CRT that would cause
>malloc behavior to change between code built with VC6/VC7?

I don't know the details, but I do recall comments that it was changed
significantly, so that may well account for the differences you see.

>We have discovered the source of the bug in remote code and have fixed it,
>but we are questioning if it is safe to move to VC7 so quickly.

Quickly!

VC8 is out now you know ;)

Dave
Signature

MVP VC++ FAQ: http://www.mvps.org/vcfaq


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.