PRB: A Process Can Map 64 (or Less) Statically-linked CRT DLLs

Article translations Article translations
Article ID: 193462 - View products that this article applies to.
This article was previously published under Q193462
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

SYMPTOMS

An attempt to load a statically-linked CRT-dependent DLL when all 64 of the TLS slots are already in use fails with the following error code:
1114 -- ERROR_DLL_INIT_FAILED.
A process running on Microoft Windows 95 or Microsoft Windows NT 4.0 can only map 64 (or less) statically-linked C run-time (CRT) dependent DLLs. On Microsoft Windows 98 and Microsoft Windows Millennium Edition (Me), a process can map up to 80 such DLLs.

A statically-linked CRT-dependent DLL is one in which the CRT library is fully compiled into the DLL.

CAUSE

The CRT library makes use of thread-local storage (TLS). Each time a statically-linked CRT-dependent DLL is mapped into a process, the CRT is initialized. During this initialization, a TLS slot is allocated. There are only TLS_MINIMUM_AVAILABLE slots available to each process. This constant is guaranteed to be at least 64 on all Win32 platforms.

RESOLUTION

If you have code-control over the DLLs, dynamically link them with the CRT library. This provides access to all of the CRT functions, without building them directly into the executable. The DLL version of the CRT is only initialized once per process.

Using the Microsoft Visual C++ compiler, you can dynamically link your project with the CRT library by compiling it as a Multithreaded DLL. You can do this by including the /MD compiler switch.

If no CRT functions are used within a DLL, you can include the linker switches /NODEFAULTLIB and /ENTRY:DllMain to bypass the CRT initialization code.

STATUS

This behavior is by design.

MORE INFORMATION

The table below lists the actual number of TLS slots available on different versions of Windows:
Collapse this tableExpand this table
Operating SystemTLS Slots
Windows 9564
Windows 9880
Windows Me80
Windows NT 4.064
Windows 20001088
Windows XP1088

REFERENCES

For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
94248 HOWTO: Use the C Run-Time
94804 INFO: Thread Local Storage Overview

Properties

Article ID: 193462 - Last Review: February 23, 2014 - Revision: 3.2
APPLIES TO
  • Microsoft Win32 Application Programming Interface, when used with:
    • Microsoft Windows 95
    • Microsoft Windows 98 Standard Edition
    • Microsoft Windows NT 4.0
    • Microsoft Windows Millennium Edition
Keywords: 
kbnosurvey kbarchive kbdll kbkernbase kbprb kbthread KB193462

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com