Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/CodeGuard    [ Add a report in this area ]  
Report #:  86335   Status: Closed
CG Error if two CRTDLLs are loaded
Project:  C++Builder Build #:  3593.25826
Version:    14.0 Submitted By:   Registered Studer AG
Report Type:  Basic functionality failure Date Reported:  7/16/2010 5:15:16 AM
Severity:    Serious / Highly visible problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   278510
Resolution: Fixed (Resolution Comments) Resolved in Build: : 15.0.3870.33544
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Steps to Reproduce:
Two Projects:
- First Project is DLL with DynamicRTL (must be Dynamic)
- Second Project is EXE (Console) with DynamicRTL

The EXE loads the DLL on startup (Binding 2). The CodeGuard reports a error saying that two different CRTDLLs are loaded (name of the DLL-Project) (c:\windows\system32\cc32100mt.dll)

This behavior is new in C++ Builder 2010. Older version worked fine. We need a solution on that, since we strongly relay on CodeGuard for Code Quality reasons.

Tomohiro Takahashi at 7/17/2010 8:00:50 PM -
I confirmed your issue and opened this report.

> - First Project is DLL with DynamicRTL (must be Dynamic)
But, generally speaking, we should not use Dynamic RTL for .DLL project.
Please take a look at this.
[Release Notes for Embarcadero Delphi 2010 and C++Builder 2010 >> Cannot Use Dynamic Link RTL if Dynamically Load DLL]

Zach Saw at 7/20/2010 6:14:03 PM -
> But, generally speaking, we should not use Dynamic RTL for .DLL project.

Using Dynamic RTL doesn't mean he's loading the DLL dynamically -- it has nothing to do with that link you provided.

And, where do you see in the link saying we shouldn't use dynamic RTL for dll projects??? -- it only says that it is a known issue and a genuine workaround is available.

Registered Studer AG at 7/18/2010 6:41:27 AM -
I'm suprised to hear this. It used to work with older versions (borland 6, CodeGear 2007) and in fact, technically it works fine (besides the message “Two different CRTLDLLs are loaded” from CodeGuard), meaning there is no memory leak or access violation.

We need DynamicRTL because we allocate memory in this DLL and the memory is released in the EXE (for instance when using std::wstring from STL). This works only using DynamicRTL, otherwise you'll get a CodeGuard message saying that the memory you are releasing was allocated in a different RTL.

I found some other interesting issue: If I compile the DLL with dynamic RTL but set _TCHAR to char (instead of wchar_t) CodeGuard has no problem (no such message “Two different CRTLDLLs are loaded”).

So I have the feeling that if the project uses _TCHAR as wchar_t the linking with cg32.lib produces a mismatch which is detected when loading the DLL.

Server Response from: ETNACODE01