>I don't know where else to report bugs, so maybe someone from Microsoft
> is reading this group
http://connect.microsoft.com/feedback?SiteID=210
> Application crashed on a library thread. The stack is below (most recent
> at top).
>
> I think is a *REALLY* bad idea for the function that is used to report
> memory allocation errors to allocate memory.
That is annoying (and then some), isn't it?
It's odd that __getptd_noexit is allocating memory. To me, that suggests
that it's running in a thread that wasn't created with _beginthread{ex}.
Are you linking with the static runtime library, by chance? (If you're
linking with the DLL runtime library, you don't need to worrk about using
_beginthread, but using the static runtime, you do).
-cd
Jochen Kalmbach [MVP] - 14 Mar 2007 14:45 GMT
Hi Carl!
> It's odd that __getptd_noexit is allocating memory. To me, that suggests
> that it's running in a thread that wasn't created with _beginthread{ex}.
From the callstack it lloks like a thread has exited and the DLL-CRT
now tries to free the thread-local-memory (__freeptd).
This is fine...
Now the problem is that the CRT wants to output the memory-leaks with
"__CrtDbgReport".
And now some of those functions tries to set the "errno" which is stored
in TLS, which was previously freed ;-)
And now it allocated again memory for this TLS... therefor it calls
__getptd_noexit.
;-)))
Nice Bug!
Greetings
Jochen
Carl Daniel [VC++ MVP] - 14 Mar 2007 14:59 GMT
> Hi Carl!
>
[quoted text clipped - 4 lines]
> tries to free the thread-local-memory (__freeptd).
> This is fine...
Ah yes - I didn't look far enough down the stack!
> Now the problem is that the CRT wants to output the memory-leaks with
> "__CrtDbgReport".
[quoted text clipped - 6 lines]
>
> Nice Bug!
Indeed!
-cd
PLS - 20 Mar 2007 01:19 GMT
I enter this bug on Microsoft Connect. The response from Micrsoft is
that it isn't worth fixing.
++PLS
> > Hi Carl!
> >
[quoted text clipped - 21 lines]
>
> -cd
Carl Daniel [VC++ MVP] - 20 Mar 2007 02:48 GMT
> I enter this bug on Microsoft Connect. The response from Micrsoft is
> that it isn't worth fixing.
If you could post a link to the bug report on Connect, other people can vote
on it.
If your bug was closed as "won't fix", that means that it won't be fixed in
Orcas (the next release of VS), but that doesn't mean that it won't be fixed
ever- especially if more people validate it/vote on it.
-cd
PLS - 20 Mar 2007 04:47 GMT
Sure. The link is
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?
FeedbackID=263647
++PLS
> If you could post a link to the bug report on Connect, other people can vote
> on it.
>
> -cd
PLS - 16 Mar 2007 05:12 GMT
No, linking with the DLLs. My setting is /MDd. I have set flags to check
memory on each alloc/free and to report leaks on exit.
The thread this error occurs on is not from my program. Mine is single
threaded. It is, however, a COM server and I know from experience that
COM creates extra threads.
++PLS
> >I don't know where else to report bugs, so maybe someone from Microsoft
> > is reading this group
[quoted text clipped - 17 lines]
>
> -cd
Ben Voigt - 16 Mar 2007 15:06 GMT
> No, linking with the DLLs. My setting is /MDd. I have set flags to check
> memory on each alloc/free and to report leaks on exit.
>
> The thread this error occurs on is not from my program. Mine is single
> threaded. It is, however, a COM server and I know from experience that
> COM creates extra threads.
Well the CRT got loaded on that thread somehow, probably by DllMain, but
possibly by some of your code calling CRT functions. COM doesn't link to
the CRT, doesn't use CRT allocators, and definitely not the debug version.
Jochen Kalmbach [MVP] - 17 Mar 2007 07:40 GMT
Ben Voigt schrieb:
>>No, linking with the DLLs. My setting is /MDd. I have set flags to check
>>memory on each alloc/free and to report leaks on exit.
[quoted text clipped - 6 lines]
> possibly by some of your code calling CRT functions. COM doesn't link to
> the CRT, doesn't use CRT allocators, and definitely not the debug version.

Signature
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Jochen Kalmbach [MVP] - 17 Mar 2007 07:46 GMT
Hi Ben!
>>The thread this error occurs on is not from my program. Mine is single
>>threaded. It is, however, a COM server and I know from experience that
[quoted text clipped - 3 lines]
> possibly by some of your code calling CRT functions. COM doesn't link to
> the CRT, doesn't use CRT allocators, and definitely not the debug version.
The CRT always initialises the TLS for *each* thread which was created
and calling DllMain with THREAD_ATTACH.
So every COM thread will trigger the CRT and allocate the TLS for this
thread (even if it is not used). Therefor every COM thread uses the CRT
if the app (or any DLL in the app) are using the DLL version of the DLL.
And if you use severay different CRT DLLs, every single CRT version will
be triggered and will allocate TLS storage.
(For example your app uses msvcrt80, one dll uses msvcrt71 an other
msvcrt70 and an other msvcrt; now you have 4 different CRTs and each
will allocate TLS for each COM thread which never uses the CRT ;) )

Signature
Greetings
Jochen
My blog about Win32 and .NET
http://blog.kalmbachnet.de/
Ben Voigt - 18 Mar 2007 03:53 GMT
> So every COM thread will trigger the CRT and allocate the TLS for this
> thread (even if it is not used). Therefor every COM thread uses the CRT if
[quoted text clipped - 4 lines]
> msvcrt70 and an other msvcrt; now you have 4 different CRTs and each will
> allocate TLS for each COM thread which never uses the CRT ;) )
That's certainly true when linking the CRT dynamically, it has a chance to
initialize on every thread in the process.
>I don't know where else to report bugs, so maybe someone from Microsoft
> is reading this group
[quoted text clipped - 6 lines]
>
> ++PLS
<snip>
Here's how to report your issue:
http://msdn2.microsoft.com/en-us/library/zzszcehe(VS.80).aspx