473,405 Members | 2,444 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,405 software developers and data experts.

Stack overflow in mixed native/managed DLL

Hi everyone,

I have a DLL which contains both native and managed C++. To
the best of my knowledge, the native code does not use MFC.

The managed C++ is basically a wrapper around the native
C++ ... so the relevant code would look like this:

public __gc class ManagedWrapper {

private:
MyNativeClass * m_pNative;

public:
ManagedWrapper() {
m_pNative = new MyNativeClass();
}
}

The native constructor isn't even getting a chance to run;
I get a stack overflow on the "new" operator. The stack
looks like this: (I'll write it out in the opposite order
to which it appears in VS.NET's call stack window, as this
is clearer in email)

VBNetApp.frmMain_Load()
ManagedWrapperDLL.ManagedWrapper()
_nh_malloc_dbg(unsigned int nSize=24, ...) Line 254 + 0x7
_lock(int locknum=4) Line 311 + 0x9
_mtinitlocknum(int locknum=4) Line 251 + 0x13
_malloc_dbg(unsigned int nSize=24, ...) Line 176 + 0x1b

Then these last four lines repeat ad infinitum until a
stack overflow occurs. The loop is clearly visible in the
code (dbgheap.c and mlock.c).

I'm using VS.NET 2003. The DLL is built in debug mode right
now (/MTd).

Can anyone tell me what I've done wrong, and/or how to
correct the problem?

Thanks.

-- graham
Nov 17 '05 #1
2 1607
The answer I found is "don't use /MT(d) for a DLL, it won't
work -- use /MD(d) instead".

This also means using msvcrt(d) instead of libcmt(d).

That's the limit of my understanding, at this point...
maybe who actually knows what all this means can briefly
explain what all of this means.

-- graham
Nov 17 '05 #2

See:
http://tinyurl.com/9opt

I had the same problem which was solved by managing how the CRT is
loaded from a Mixed-Mode DLL. The article contains a 'Knowledge Base
link' (http://support.microsoft.com/?id=814472) with instuctions on
how to correct the problem.
--
Dan Peterson
------------------------------------------------------------------------
Dan Peterson's Profile: http://forums.yourdomain.com.au/member.php?userid=2
View this thread: http://forums.yourdomain.com.au/showthread.php?t=14995

Nov 17 '05 #3

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

Similar topics

1
by: Mike Kamzyuk | last post by:
Hello all. Basically, I need to call a mixed-mode dll's function (which uses managed code) from a native or mixed-mode dll function (which does not use managed code). I'm wondering if this could...
8
by: Ted Miller | last post by:
Hi folks, I'm looking at moving a large base of C++ code to .Net under tight time constraints. The code runs in mission-critical environments, and I am extremely concerned about the loader lock...
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
8
by: Nadav | last post by:
Hi, I am writing a performence critical application, this require me to stick to unmanaged C++ as performance is much better using unmanaged C++ ( about 33% better ), Still, I am trying to avoid...
1
by: Bern McCarty | last post by:
Our project consists of some mixed .dlls and recently we noticed that it had slowed down. When I investigated I figured out that some inlineable methods of a native C++ type were compiled into (not...
4
by: quortex | last post by:
Hey all, I have been working on a project which consists of Native C++ code and managed C# code. In order for the managed C# code to be able to access the native layer I wrap some objects using...
3
by: Lonewolf | last post by:
Hi all, I'm having difficulties passing data back to managed class from my native class when the data is generated from within a native thread in the native class itself. I will give the following...
3
by: Mali Guven | last post by:
Hello, I have a native DLL (written in C) which is supposed to call a managed DLL (was written in C#, and an entry point was injected modifying the ildasm'd code). The exectuable calls the...
8
by: Edward Diener | last post by:
By reuse, I mean a function in an assembly which is called in another assembly. By a mixed-mode function I mean a function whose signature has one or more CLR types and one or more non-CLR...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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.