473,320 Members | 1,900 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,320 software developers and data experts.

malloc() causes an Access Violation when compiling with the /MT switch

Hi... I have created a utility library with VC++ 7.1 which is used by a VB 6
client. The library creates a secondary thread of execution in order to
listen for connections on a socket. The problem I am experienceing is that
the DLL works fine when it is compiled with the /MTd switch (static
Multithreaded Debug CRT) but as soon as I change it to the /MT switch
(static Multithreaded CRT), malloc() causes an Access Violation exception
after just a few calls. The exception is being raised by HeapAlloc() in
line 212 of malloc.c .

The first few calls to malloc() are allocating very small memory blocks, in
the range of 28 - 150 bytes. The call to malloc() which always raises the
exception when used with the /MT switch is trying to allocate a block of
16Kb.

When I debug the DLL with the /MTd switch, no exception occurs and there is
no assertion failures or debugging messages from the CRT or NT Heap to
indicate that there could be a problem. Also, when writing to the memory
allocated before the offending line is reached, I am very careful to not go
beyond the length of the previously allocated blocks so I'm pretty sure it
is not a buffer over-run problem.

The heap seems to be corrupting for some reason, but I can't figure out why
it only happens with the non-debug builds of the CRT.

Any help would be greatly appreciated.
Clive
Nov 17 '05 #1
0 1840

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

Similar topics

1
by: SCS | last post by:
System: Windows 2003 Server PHP 5 Final IIS 6 Problem: Every time I run a PHP page I get "PHP has encountered an Access Violation at 017473CD" at the bottom of the page... But even worse,...
3
by: Rossel Nathanaël | last post by:
146: unsigned short *sDate; 147: 148: sDate = (unsigned short *)malloc(100); 17E4157C 6A 64 push 64h 17E4157E E8 05 4C 00 00 call malloc (17e46188)...
35
by: ytrama | last post by:
Hi, I have read in one of old posting that don't cast of pointer which is returned by the malloc. I would like to know the reason. Thanks in advance, YTR
13
by: Jean Pierre Daviau | last post by:
I am a newbe not only in C but in programming. I am actually reading K&R. This is why I tried to run your application. It seems not to be running on my system. There is maybe a copy/paste...
13
by: ppateel | last post by:
Hi, I am new to c++ and I am converting a c program to c++. I changed malloc call to new and I am getting an exception violation. Here is the relevant piece of code. Compiler vc++ 7.0 (.Net...
68
by: James Dow Allen | last post by:
The gcc compiler treats malloc() specially! I have no particular question, but it might be fun to hear from anyone who knows about gcc's special behavior. Some may find this post interesting;...
10
by: Francine.Neary | last post by:
I've been trying to understand the design decision to have one (well, three of course, but essentially one) allocation function that returns a pointer guaranteed to be aligned for any type. It...
2
by: jthep | last post by:
I'm trying to get this piece of code I converted from C to work in C++ but I'm getting an access violation error. Problem occurs at line 61. Someone can help me with this? The function...
39
by: Martin | last post by:
I have an intranet-only site running in Windows XPPro, IIS 5.1, PHP 5.2.5. I have not used or changed this site for several months - the last time I worked with it, all was well. When I tried it...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.