Re: question about CRT boundries

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: thePoet (thepoet_usenet_at_dfsoftware.com)
Date: 03/06/04


Date: Sat, 06 Mar 2004 21:18:09 GMT


> CAtlString uses HeapAlloc et al for memory management, using process
> default heap.

There is something I'm missing in all this discussion, which is, what
causes an allocation to be run in one version of the CRT versus another.
Here is an example that I know doesn't have problems. I will then
contrast it with the string example to try to find out where the
diference lies. Please, everyone, fill in my knowledge gaps, cecause
something isn't adding up for me.

Working example:

I have often developed classes that were defined in one dll and passed
into another. One example is our DynamicTableType. This object is
defined in a utility dll, created in the application, and then passed
into plugins (its in the utility to make it easier for plugin
development). The plugins make a series of calls into the
DynamicTableType that onternally causes it to allocate and sometimes
memory internally. When the DynamicTableType is deallocated by the
application, its creator, there are no memory issues. All the
allocationa and deallocations take place in the same CRT instance, even
though often time the CRT instance of the plugin is completely different
than that of the application.

Failing example:

I create a basic_string in the executable, pass it into dll that runs in
a different CRT. That dll makes a call that causes it to internally
allocate memory. The string is returned to its creator and deallocated,
and the system crashed because the internal memory of the string was
created in another CRT instance.

To sum up:

What is the difference between the two situations. Is the memory
allocation problem caused by the dll knowing the code of basic_string
and thus triggering it in the scope of the library instead of the scope
of the location it was created in? Is the only reason that the first one
works is because the plugin doesn't know how to execute DynamicTableType,
so it must call back into the library it was defined in? If so, doesn't
this make coding any template that will be passed across boarders
without using HeapAlloc(GetProcessHeap()...) extremely dangerous?



Relevant Pages

  • Re: Problem with samba netdrive plugin
    ... in firefox, ... The Netdrive plugin ... least, in "linear memory usage by process", that I don't understand ... active connections via PEER, I can only rely on one active samba ...
    (comp.os.os2.networking.misc)
  • Re: Using dlopen on the samefilename twice
    ... >>memory, as they need to be passed different parameters. ... Using mmap/munmap/mprotect allows such control of the address space in Linux. ... You can also make the plugin as a ET_EXEC file instead of a ET_DYN file. ... See "Linker Scripts": info ld; ...
    (comp.os.linux.development.apps)
  • Re: Using dlopen on the samefilename twice
    ... > I need a way to load a shared object into memory twice using dlopen. ... > plugin instantiation and pass it different values. ...
    (comp.os.linux.development.apps)
  • Using dlopen on the samefilename twice
    ... I need a way to load a shared object into memory twice using dlopen. ... I have a plugin for a cross-platform program I'm helping to make, ... plugin instantiation and pass it different values. ...
    (comp.os.linux.development.apps)
  • Re: Why do we need executables in certain formats ?
    ... > complex binary formats was that programs need to be relocated, ... > perhaps linked with libraries. ... Modern virtual memory processors can locate to ... > has a hidden problem with the new .DLL. ...
    (comp.lang.asm.x86)