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

  • Home
  • SEARCH
  • 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 8928047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:20:59+00:00 2026-06-15T08:20:59+00:00

I am trying to debug a use after free error in my code using

  • 0

I am trying to debug a use after free error in my code using Valgrind.

My code is crashing when it tries to access an object that was previously deleted. Is there some way to see who deleted the object in this case using Valgrind?

I ran Valgrind using the following option, but it only catches the crash, and shows where it occurred. I’m hoping to get details on where the object was deallocated:

valgrind –tool=memcheck

  • 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-15T08:21:00+00:00Added an answer on June 15, 2026 at 8:21 am

    This is what I use in these cases:

    valgrind --track-origins=yes
    

    In case of a use-after-free, it will show you the stacktrace of the function that free’d the memory/deleted the object.

    Please read the manpage of Valgrind for the caveats, specifically the ones about performance. If your issue is a concurrency problem, a slower Valgrind might change the timing properties of your program and possibly change (either reduce or increase) the probability to hit the bug.

    --track-origins=<yes|no> [default: no]
        Controls whether Memcheck tracks the origin of uninitialised
        values. By default, it does not, which means that although it can
        tell you that an uninitialised value is being used in a dangerous
        way, it cannot tell you where the uninitialised value came from.
        This often makes it difficult to track down the root problem.
    
        When set to yes, Memcheck keeps track of the origins of all
        uninitialised values. Then, when an uninitialised value error is
        reported, Memcheck will try to show the origin of the value. An
        origin can be one of the following four places: a heap block, a
        stack allocation, a client request, or miscellaneous other sources
        (eg, a call to brk).
    
        For uninitialised values originating from a heap block, Memcheck
        shows where the block was allocated. For uninitialised values
        originating from a stack allocation, Memcheck can tell you which
        function allocated the value, but no more than that -- typically it
        shows you the source location of the opening brace of the function.
        So you should carefully check that all of the function's local
        variables are initialised properly.
    
        Performance overhead: origin tracking is expensive. It halves
        Memcheck's speed and increases memory use by a minimum of 100MB,
        and possibly more. Nevertheless it can drastically reduce the
        effort required to identify the root cause of uninitialised value
        errors, and so is often a programmer productivity win, despite
        running more slowly.
    
        Accuracy: Memcheck tracks origins quite accurately. To avoid very
        large space and time overheads, some approximations are made. It is
        possible, although unlikely, that Memcheck will report an incorrect
        origin, or not be able to identify any origin.
    
        Note that the combination --track-origins=yes and
        --undef-value-errors=no is nonsensical. Memcheck checks for and
        rejects this combination at startup.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to debug a web page that makes heavy use of events, and
I'm trying to debug an ASP.NET webapp that's configured to Use Local IIS Web
I'm trying to use Firebug to debug some Javascript that entails blur and focus
I'm trying to use my debug keystore so I can get a key for
I'm trying to use GDB (v 7.3.1) from macports to debug an executable compiled
I'm trying to understand how to use firebug to debug my Javascript. So I
I am trying to use MSBuild release mode, but it always defaults to debug.
I am trying to use NuSoap in PHP 5.3. When I debug my script
I am having real problems trying debug my code to malfunctioning print statements. I
I have been trying to setup Symfony2 on Windows so that I can use

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.