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 4271180
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:24:26+00:00 2026-05-21T07:24:26+00:00

I understand that this is a very broad question, but I was very curious

  • 0

I understand that this is a very broad question, but I was very curious about this so I decided to ask. Please understand that what information I give is unfortunately all that I have 🙂


I was wondering, in a C++ program, what possible situations could the following case happen in:

The following is the (mimicked) code snippet. It uses a class whose implementation and member function implementation is hidden in a DLL:

namespaceFromSomeDll::userDefinedClass myObject = new namespaceFromSomeDll::userDefinedClass();
myObject->someMemberFunction();
delete myObject;

The situation:

This code snippet as is will throw an exception on the third line saying “Cannot access memory location” or something along these lines. There is no mention of not being able to access “protected memory”, (ie: not like a buffer overflow), just cannot access memory.

Now, if the second line is commented out:

namespaceFromSomeDll::userDefinedClass myObject = new namespaceFromSomeDll::userDefinedClass();
// myObject->someMemberFunction();
delete myObject;

…there is no exception and the code runs to the end and the delete call executes normally.

I was wondering what the member function call could possibly be doing to cause this problem? What kind of action could it perform that would “lock” the memory, or maybe even change the object location or deallocate the pointer or something? (Can that even happen?)


This question was actually asked of me by someone else who slightly looks up my slightly-higher programming skill, and I was totally unable to answer. They were working with a third party library and trying to troubleshoot something that yet another person had written. Convoluted, I know, and thus the lack of any further information.

  • 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-05-21T07:24:27+00:00Added an answer on May 21, 2026 at 7:24 am

    The problem with declaring and implementing a class in a DLL and simply using it from outside is that “outside” needs to know the layout of your class. At a minimum the calls to new/ delete operators must know how much memory must be allocated and freed.

    Based on what you said, my best guess is that the client is using header file, which declares namespaceFromSomeDll::userDefinedClass, that doesn’t match the header file that was used to build the actual DLL (i.e. someone added or removed a member variable in a DLL and rebuilt it after the client code was already built). Because of that, when you call someMemberFunction(), it access memory which is outside of the allocation bounds and you end up with a heap corruption.

    This is what’s causing the crash. Otherwise, there’s no concept of “locked” memory in a sense that I think you are thinking of.

    This is a very common issue with having multiple binary modules interact with each other. For this reason COM (and other custom implementations) use class factory methods which perform the actual object allocations within the DLL code and also instead of destroying the object yourself, DLL would implement a method which would clean up the object on your behalf (in COM, this is done through reference counting, so the object deletes itself whenever it is no longer used by anyone).

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

Sidebar

Related Questions

I understand that this is a very broad question, but a short it depends
I understand that this is a very long question, but i wanted to ask
I understand that this may seems a very basic question, but I always thought
I understand that this a very noob problem, but when I try to create
I understand that this is a probably a noob-ish question, but I've had no
I understand that this question may seem somewhat ungrounded, but if someone knows anything
I understand that this question has likely been asked, but I don't understand the
I understand that this question is based on a very old programming language, and
I am very new to Silverlight development. I understand that this is client side
I understand that this question may be subjective, this is why I need an

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.