DLL hell

In computing, DLL hell is a colloquial term for the complications that arise when working with dynamic link libraries, (DLLs), used with Microsoft Windows operating systems.Although the term is Windows-specific, and the more general term is dependency hell, the rhyme is often used to depict a dependency hell case.

It takes a number of forms, detailed below. This problem often shows up in a Windows alert pop-up that reports something similar to "A Required DLL File, Z.DLL, was not found" or "The procedure entry point Y couldn't be located in X.DLL" when users try to run an application, or during startup. This can also manifest itself more quietly as applications just not working properly.

Problems

There are a number of problems commonly encountered with DLLs – especially after numerous applications have been installed and uninstalled on a system.The difficulties include conflicts between DLL versions, difficulty in obtaining required DLLs, and having many unnecessary DLL copies.

;Incompatible versions: A particular version of a library can be compatible with some, and incompatible with other, programs that use it. Windows has been particularly vulnerable to this because of its emphasis on dynamic linking of C++ libraries and Object Linking and Embedding (OLE) objects. C++ classes export many methods, and a single change to the class (such as a new virtual method) can make it incompatible with programs that were built against an earlier version. Object Linking and Embedding has some very strict rules to prevent this -- interfaces are required to be stable and memory managers are not shared. But this is not enough, for the semantics of a class can change. A "bug" fix for one application may be the removal of a "feature" from another. Before XP, Windows was vulnerable to this because the COM class table was shared across all users and processes. Only one COM object, in one DLL/EXE could be declared as having a specific COM ClassID. If any program needed to create an instance of that class, it got whatever was the current centrally registered implementation. As a result, an installation of a program that installs a new version of a common object may inadvertently break other people's programs.

;DLL stomping: A common and troublesome problem occurs when a newly-installed program overwrites a working system DLL with an incompatible version. A famous example of this was the ctl3d.dll library in Windows 3.1 that was documented by Microsoft, which caused numerous variations to appear in the wild. This was solved by replacing it with a new, library ctl3dv2.dll. DLL Stomping occurs because:* Microsoft in the past distributed runtime DLLs as shared system components [ [http://support.microsoft.com/kb/326922 Redistribution of the shared C runtime component in Visual C++ 2005 and in Visual C++ .NET] ] , (originally C:WINDOWS and C:WINDOWSSYSTEM), as a way of efficiently sharing code in a shared-memory OS with limited RAM and disk space. Consequently, third-party developers also distributed these in such a manner.:* Although somewhat discouraged today, applications installed by anyone with Administrator rights has the ability to install DLLs into the system directories, and edit the registry to register new DLLs as COM objects. This can result in the old version becoming live.:* Windows applications are permitted to include OS updates in their own installation programs. That is, many Microsoft DLLs are "redistributable", meaning the applications get to include them if they need the services of the particular libraries.:* Windows Installers historically were a commercial product only available at a price. Many people tried to write their own.Fact|date=August 2008 :* In older versions of Windows, there was no standard way to determine which version of a library was newer. Overwriting existing artifacts or skipping the copy if the DLL was already installed were the only two options available. If a dialog was presented offering these options, the application being installed received support calls. If the DLL copy was skipped, again, support calls. If the DLL was stomped on, your application worked. Other applications may have broken, but that was their problem. :* Sometimes the OS itself stomps on DLLs. For example, Windows 2000 would install black and white printer DLLs on top of color-aware DLLs, if a black and white printer was installed after the color printer. [ [http://support.microsoft.com/kb/830490 HP Color LaserJet printer prints only in grayscale or in black-and-white on your Windows 2000 SP4-based computer ] ]

;Registry Da
COM and other parts of Windows, the Registry is used to decide which DLL to use. If the registry is updated incorrectly, the wrong DLL will be loaded. This can be caused by device driver installations that register the wrong libraries to load, or the wrong COM Object factories. This effect can usually be replicated by installing an old version of a Microsoft Office application onto a system which already has a later version installed.

;Shared in-memory code pages: A subtler problem occurs because once a DLL is loaded, Windows will use the running version, until no applications are using it. Thus even if the system DLL is ok, or an application has a working local copy, if a "previous" application has started with an incompatible version, the new application won't work. This can manifest itself either as "an application doesn't work if a different application is running", or more mysteriously as "an application doesn't work if a different application has been run (but needn't be running any longer)": if App A loads a corrupt or incompatible library, then App B is launched and uses that library, that version will stay in memory even after App A exits (so long as App B is still running), so App B might fail to work because of App A, even though App A is no longer running. More subtly yet, a third application App C may fail to run (so long as App B is still running) even if it is started after App A has exited.

;Lack of serviceability: In direct conflict with the DLL stomping problem: If updates to a DLL do not affect all applications which use it, then it becomes "much" harder to 'service' the DLL - that is, to eliminate problems which exist in the current versions of the DLL. (Security fixes are a particularly compelling, and painful, case.) Instead of fixing just the latest version of the DLL, the implementor must ideally make their fixes, and test them for compatibility, on every released version of the DLL.

Causes

DLL incompatibility was possible because Windows lacked a number of features:
*enforced standard versioning, naming, and file system location schemata for DLLs;
*enforced standard method for software installation and removing (package management);
*centralized authoritative support for DLL Application Binary Interface management and safeguards, allowing incompatible DLLs with the same file name and internal version numbers to be released;
*overly simplified management tools, preventing the identification of changed or problematic DLLs by users and administrators.

DLL hell was a very common phenomenon on pre-Windows 2000 versions of Microsoft operating systems, the primary cause being that the operating system did not restrict DLL installations. Application installers were expected to be good citizens and verify DLL version information before overwriting the existing system DLLs. Standard tools to simplify application deployment (which always involves shipping the dependent operating system DLLs) were provided by Microsoft and other 3rd party tools vendors. Microsoft even required application vendors to use a standard installer and have their installation program certified to work correctly, before being granted use of the Microsoft logo. The good citizen installer approach did not mitigate the problem, as the rise in popularity of the Internet provided more opportunities to obtain non-conforming applications.

olutions

Various forms of DLL hell have been solved or mitigated over the years.

tatic Linking

One of the simplest solutions to DLL hell in an application is to statically link against all the libraries. This is common in C/C++ applications, where, instead of having to worry about which version of MFC42.DLL is installed, the application is compiled to be statically linked against the same libraries. This eliminates the DLLs entirely, and is viable for standalone applications that are only using libraries -such as Microsoft Foundation Class Library- that offer a static option.

DLL Stomping

The DLL overwriting problem (referred to as "DLL Stomping" inside Microsoft) was somewhat reduced with Windows File Protection (WFP) [ [http://www.microsoft.com/whdc/winlogo/drvsign/wfp.mspx Windows File Protection and Windows] ] that was introduced in Windows 2000. This prevents unauthorized applications from overwriting system DLLs, unless they use the specific Windows APIs that permit this. There is still a risk that updates from Microsoft (such as Internet Explorer 7) are incompatible with existing applications.

Third-party applications cannot stomp on OS files unless they bundle windows updates with their installer, or if they disable the Windows File Protection service during installation.

Some other features that help to mitigate the problem are
# DLLs can now support VERSION resources. These are standard binary fields embedded in the DLL, which include DLL author and version information. Installers can use these to determine whether a DLL being considered for installation is in fact older than the version already installed.
# Installation tools are now bundled into Microsoft Visual Studio, the main environment for Windows development. These tools perform version checking before DLL installation, and can include predefined installation packages in a .MSI installation. This allows third party applications to integrate OS component updates without having to write their own installers for these components.
# System Restore can recover a system from a bad installation, including registry damage. While this does not prevent the problem, it makes it easier to recover from.

Conflicting DLLs

The solutions here consist of having different copies of the same DLLs for each application, both on-disk and in memory.

An easy manual solution to conflicts was placing the different versions of the problem DLL into the applications' folders, rather than a system-wide folder. This works so long as the applications are not run simultaneously. However, OLE prevented this before Windows XP, because earlier versions of Windows had a single registry of COM objects for all applications.

The XP solution is"Side-by-Side Component Sharing"( [http://msdn2.microsoft.com/en-us/library/ms811700.aspx MSDN page] ), which loads separate copies of DLLs for each application that requires them (and thus allows applications that require conflicting DLLs to run simultaneously).

This eliminates conflicts, but also eliminates one of the primary benefits of sharing DLLs between applications – reducing memory use (with modern computers which have plenty of disk space and memory, it can be a reasonable approach). Other benefits such as bug fixes and security updates may be affected, and errant and insecure DLLs may not be updated during automated processes.

Countermeasures

There are several countermeasures known to avoid DLL hell, which have to be used simultaneously for optimal results:
* Registration-free COM: Windows XP introduced a new mode of COM object registration called "Registration-free COM" that was not well-publicized due to the simultaneous release of information related to .NET. This feature makes it possible for applications that need to install COM objects to store all the required COM registry information in the application's directory, instead of in the global registry, where strictly speaking if only a single application will ever use it is all that is needed. Thus, it provides a mechanism for multiple versions of the same DLL to be present at the same time as needed to cater for multiple applications (Microsoft calls this "Side-by-side Assemblies" [ [http://msdn2.microsoft.com/en-us/library/aa376307.aspx Side-by-side Assemblies (Windows)] ] ). DLL hell can be substantially avoided using Registration-free COM, the only limitation being it requires at least Windows XP or later Windows versions and that it must not be used for EXE COM servers or system-wide components such as MDAC, MSXML, DirectX or Internet Explorer.
* Shipping the operating system with a capable package management system that is able to track the DLL dependencies, encouraging the use of the package manager and discouraging manual installation of DLLs.
* Having a central authority for distributing the library. Changes to the library can be submitted to this authority; thus, it can make sure compatibility is preserved in the developed branches. If some older software is incompatible with the current library, the authority can provide a compatibility interface for it, or bundle the old version as a distinct package.
* If software developers need to customize a library, and if the main library release is unlikely to incorporate the changes that they need, they can ship the customized DLL for the program's private use (commonly by placing it in the program's private directory) or statically link the program against the customized library.
* Proper software design is paramount. DLLs are best for modularizing applications and the system's components and as third-party libraries; their usage is not imperative in all cases. For example, if an application needs a library that will not be used anywhere else, it can be linked statically, with no space penalty and with a speed gain.

DLL hell as motivation for .NET

In February 2002, Microsoft publicly unveiled the .NET Framework, which included a new version of a package deployment system called "assemblies". [ [http://msdn2.microsoft.com/en-us/library/ms973843.aspx Simplifying Deployment and Solving DLL Hell with the .NET Framework] ] This framework also provided support for a common language runtime (essentially moving much DLL code to a base foundation class). This concept, along with file versioning, is often seen as one of the last operating system constructs that had failed to bridge the gap between OpenVMS and Windows NT, which shared a common operating systems architecture. Fact|date=July 2008

See also

* Dependency hell

References

External links

* [http://msdn2.microsoft.com/en-us/library/ms811694.aspx The End of DLL Hell] on MSDN
* [http://www.microsoft.com/technet/technetmag/issues/2007/01/WindowsConfidential/default.aspx Getting Out of DLL Hell] on Microsoft TechNet
* [http://msdn.microsoft.com/en-us/library/ms973843.aspx Simplifying Deployment and Solving DLL Hell with the .NET Framework] on MSDN
* [http://msdn.microsoft.com/msdnmag/issues/1000/metadata/default.aspx Avoiding DLL Hell: Introducing Application Metadata in the Microsoft .NET Framework] by Matt Pietrek
* [http://www.ddj.com/dept/windows/184416837 Dr. Dobb's on DLL Hell] (details on LoadLibraryEx)
* [http://discuss.fogcreek.com/joelonsoftware/default.asp?cmd=show&ixPost=2899 Joel on Software discussion]
* [http://dllcity.com/dll-hell.php Great Article on DLL Hell]


Wikimedia Foundation. 2010.

Look at other dictionaries:

  • DLL hell — (DLL кошмар, буквально: DLL ад)  тупиковая ситуация, связанная с управлением динамическими библиотеками DLL в операционной системе Microsoft Windows. Аналогичная проблема в других ОС носит название Dependency hell. Сущность проблемы… …   Википедия

  • DLL Hell — Saltar a navegación, búsqueda El término DLL Hell (infierno de las DLL) se refiere a los problemas ocasionados por las DLL (bibliotecas de enlace dinámico). Estas bibliotecas consisten en un conjunto de código común que puede estar compartido… …   Wikipedia Español

  • DLL Hell — In computing, DLL Hell is a term for the complications that arise when working with dynamic link libraries (DLLs) used with Microsoft Windows operating systems,[1] particularly legacy 16 bit editions which all run in a single memory space. While… …   Wikipedia

  • DLL Hell — Der Ausdruck DLL Konflikt (auch DLL Hell, deutsch: „DLL Hölle“ genannt) bezeichnet ein Problem, das durch die Installation von Dynamic Link Library (DLLs) auf den Betriebssystemen der Windows Reihe (Windows 3.x, Windows 9x, Windows ME, Windows NT …   Deutsch Wikipedia

  • DLL Hell — El término DLL Hell (El infierno de las DLLs) se refiere a los problemas ocasionados por las DLLs (Bibliotecas de enlace dinámico). Estas bibliotecas consisten en un conjunto de código común que puede estar compartido entre varias aplicaciones.… …   Enciclopedia Universal

  • DLL hell — noun Problems caused by incompatible versions of a DLL (dynamic link library). A more succinct way to say this is that the versioning the CLR enforces for strong named assemblies means the end of DLL hell …   Wiktionary

  • DLL — (англ. Dynamic link library  динамически подключаемая библиотека)  понятие операционных систем Microsoft Windows и IBM OS/2; динамическая библиотека, позволяющая многократное применение различными программными приложениями. K DLL… …   Википедия

  • Hell (disambiguation) — Hell, according to many religious beliefs, is a place of suffering during afterlife where the wicked or unrighteous souls are punished.* Hell in Christian beliefs * Hell in popular culture * Problem of Hell, a variant of the problem of evil *… …   Wikipedia

  • DLL-Hölle — Der Ausdruck DLL Konflikt (auch DLL Hell, deutsch: „DLL Hölle“ genannt) bezeichnet ein Problem, das durch die Installation von Dynamic Link Library (DLLs) auf den Betriebssystemen der Windows Reihe (Windows 3.x, Windows 9x, Windows ME, Windows NT …   Deutsch Wikipedia

  • DLL-Konflikt — Der Ausdruck DLL Konflikt (auch DLL Hell, deutsch: „DLL Hölle“ genannt) bezeichnet ein Problem, das durch die Installation von Dynamic Link Library (DLLs) auf den Betriebssystemen der Microsoft Windows Reihe entstehen kann. Vorwiegend sind ältere …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”

We are using cookies for the best presentation of our site. Continuing to use this site, you agree with this.