Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8685311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:32:10+00:00 2026-06-12T22:32:10+00:00

Have an EXE which implicitly loads some DLL’s and others explicitly (LoadLibrary). This EXE

  • 0

Have an EXE which implicitly loads some DLL’s and others explicitly (LoadLibrary). This EXE is executing its ExitProcess (1 thread in process left) and as part of that busy unloading a DLL, say A.DLL.

A.DLL (unfortunately) has a static. The atexit callback is called and this static’s destructors begins to be called, leaving a trail of destructors, until a destructor decides to do some cleanup and loads a DLL to do this. This DLL performs some methods until a crash occurs due to memory access violation since a static it was about to use in this DLL is no longer present. Looking at the stack trace of this static, its destructor has been called already as part of its DLL unload.

What happened? The DLL was loaded, performed some methods, goes to use a static (in the same DLL) but this has been destructed (static only gets destructed when dll is unloaded). So is it in a half limbo state of executing methods but is also being destructed?

The EXE seems in the context of __tmainCRTStartup which implies the user created main has returned? Are DLL’s unloaded while in the context of the user main or tmainCRTStartup?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:32:11+00:00Added an answer on June 12, 2026 at 10:32 pm

    It’s this simple: Destructors of static objects are called in reverse order of their creation, this is internally done by registering atexit callbacks. The only case where this differs is if you manually unload (FreeLibrary) a DLL.

    The problem you describe only shows that you have a cyclic dependency, which can easily happen with static constructors/destructors. You should be careful in what you do in destructors, especially loading a DLL at this point seems quite dangerous to me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a c# exe which uses some c++ dlls . I use DllImport
Assume I have an executable called 'exe' which spawns a child process. This child
I have an EXE file using a DLL file which is using another DLL
I have a Visual Studio 2010 C# project which creates an .exe and this
I have a call to powershell.exe that looks like this, and which works from
I have an exe which has to be built in .Net 2.0 Can this
I have a C++ Windows application myapp.exe which loads several plug-ins. Plug-ins need to
I have created a Class Library (called as GNGEngine.dll) which performs some image processing
I have a C++ console Exe which does some progamming. Now i wanted to
I need to have an executable file (.exe) which takes some parameters from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.