473,395 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

My MSVC 6 DLL now has HEAP corruption problems

Need help with HEAP CORRUPTION and my MSVC 6 DLL

I have a MSVC 6 DLL that I've written. It is used heavily by a Delphi 6 app
I've written.

For two months everything has been working fine. Then I changed some things
in the code recently, and now I'm getting what looks like severe corruption
of the heap.

I am wondering if it is some strange interaction between the Delphi app and
my MSVC 6 DLL, that I somehow caused with a recent change to either of the
programs. I say this because when I run the exact same library code that is
"wrapped" in the DLL, in a Win32 Console test application which I created to
test the code, it works perfectly. It is only, and only recently, when I
run it as a DLL with the Delphi app as a client, that I see the heap
corruption. I checked all the project settings for the dependent libraries
my DLL links in, and my DLL project settings, and everyone is set to Debug
Multithreaded DLL for the code generation option (and all other settings are
the same too). I am currently testing in Win32 Debug configuration with
gflags monitoring the process in "/full" mode.

I say the heap is corrupted because of the following evidence:

- There is a setup function in the DLL code where a large amount of
calloc()'s occur in a loop. Each calloc() does one allocation of a 12 byte
elements (i.e. 12 bytes total). Normally this only consumes a couple of
megabytes of memory and executes fast. I traced through the calloc() calls
and with each calloc() over 4000 bytes (4k) are being allocated!. After a
few seconds. the memory consumption of the process as reported by the Win2k
task manager, shoots up to almost 280 megabytes of memory. Pretty soon
thereafter I get a "System is low on virtual memory" dialog box and finally
all calloc() calls begin to fail. Meltdown.

Before I ran gflags, I was getting weird access violations all over the
place.

As I rack my brain trying to think what I may have done recently to cause
this, the only major change I can think of was the including of <crtdbg.h>
in several source files that use "assert". But those includes are in IFDEF
blocks and are not included when I build using the Win 32 release
configuration, yet the heap corruption still occurs. This would seem to
indicate that the <crtdbg.h> change is not a factor.

Once more, this does not happen with the exact same code when that code is
linked into an MSVC Win32 Console application, only when running as a DLL.

So what can I try to do to fix this? What kind of tests can I try?

Thanks,
Robert
Nov 14 '05 #1
2 2609
In article <Z8********************@adelphia.com>,
Robert Oschler <no************@nospam.com> wrote:
I have a MSVC 6 DLL that I've written. It is used heavily by a Delphi 6 app
I've written.


The problems you are seeing are not at all portable. DLL's and Delphi
are not part of C, so you would get much better assistance in
one of the Windows programming newsgroups.
--
Feep if you love VT-52's.
Nov 14 '05 #2
Walter Roberson wrote:
In article <Z8********************@adelphia.com>,
Robert Oschler <no************@nospam.com> wrote:
I have a MSVC 6 DLL that I've written. It is used heavily by a Delphi 6 app
I've written.


The problems you are seeing are not at all portable. DLL's and Delphi
are not part of C, so you would get much better assistance in
one of the Windows programming newsgroups.


The problem is almost certainly a C problem such as double freeing or
running off the end of a buffer and nothing to do with DLLs or Delphi.

It probably works from the console app but not from Delphi for the same
reason any program invoking undefined behaviour "works" for a simple
test but not when doing an important demonstration or delivery. Blind luck.

*If* the OP can post code that does not use MS extensions, then it can
be looked at here. Depending on what the DLL does this *might* be
possible. If not, it will will have to be looked at in a Windows
programming group.

The same would apply with a shared library for *nix.

<OT>I know through personal experience that calling DLLs written in MSVC
from Delphi applications works as it should.</OT>
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steffen | last post by:
I'm searching for a heap monitoring tool, 'cause I have a heap crash in my software (c++). It occurs only after some days running my program. The crash happens by allocating string-buffers deep in...
2
by: Riley DeWiley | last post by:
I have a program which must call into third party code that might do a wild write (I have been getting ASSERTs and access violations in debug code when I am freeing pointers after a call into that...
26
by: jamesbeswick | last post by:
I've been using Access since version 97 and I've migrated to 2003. I've noticed a substantial number of strange ActiveX/OLE and code corruption problems when writing databases. The only solution...
9
by: William L. Bahn | last post by:
I am having a strange problem - and I suspect it is something specific to my compiler - but want to get a read on the Standard C portion of it first. Basic Question: Under the C Standard, under...
11
by: Florian A. | last post by:
Hi everyone! I'm trying to write a global hook in C# and C++/CLI. I'm almost done if there wasn't this little delegate problem. I get the function pointer to a delegate and pass it to my...
1
by: syntheticpp | last post by:
Here a compiler bug of msvc 8 (14.00.50727.42): fatal error C1060: compiler is out of heap space Without the virtual inheritance it compiles fine. GCC has no problems. Code (tested with...
23
by: Dave G | last post by:
Since upgrading one of my clients from A97/W2000 to A2003/XP they have suffered no end of data corruption problems, mainly involving one of the main tables. The corruption can result in one...
9
by: Arsalan Ahmad | last post by:
Hi all, I have developed a static library which I am using in one of my application. In my library I have created my own heap and all the objects (class objects) in my application are created in...
8
by: Martin the Third | last post by:
Hi, I need some help! I'm writing an infinite-precision floating point library called ipfloat (I know infinite is a misnomer - but arbitrary was taken). A quick overview: I'm storing numbers as...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.