Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Locating the source of heap corruption (setup and general guidelines)
Qt 6.11 is out! See what's new in the release blog

Locating the source of heap corruption (setup and general guidelines)

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 858 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • deisikD Offline
    deisikD Offline
    deisik
    wrote on last edited by deisik
    #1

    I have a random heap corruption in my app which is using an external dll that exchanges data with an Internet server

    The crash occurs after an arbitrary amount of time like 2-3 hours up to a couple days

    So the problem is in identifying the command and, most importantly, the module where the heap gets corrupted and what leads to the corruption (not where the error manifests itself) as the issue may well be with the dll, not my code

    Now I'm trying to understand how to use Application Verifier to track down heap corruptions. For demonstration purposes, I delete the same pointer twice and Application Verifier shows me the address of the offending code and the address causing the corruption

    Something like this:

    VERIFIER STOP 0000000000000013: pid 0x19D0: First chance access violation for current stack trace
    
         00000267AD9BD030 : Invalid address causing the exception.
         00007FF734962533 : Code address executing the invalid access.
         000000D98C1289B0 : Exception record.
         000000D98C1284C0 : Context record.
    

    But this is not what I want to know as I can see that in debugger. In this case specifically, I want to know where the memory has been released for the first time (without the advantage of prior knowledge), and, more generally, to learn how to locate the source of heap corruptions, not where they manifest themselves

    I've been trying to follow the steps laid out in this article:
    https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/application-verifier-debugging-application-verifier-stops

    But the commands related to debugging heap errors simply don't work in the cdb command window in QtCreator, starting with:

    !heap -p
    

    which produces:

    unable to resolve ntdll!RtlpStackTraceDataBase
    unable to read 0000000000000000
    

    So how can I trace this error (and other heap corruption errors) with Application Verifier and cdb in QtCreator?

    deisikD 1 Reply Last reply
    0
    • deisikD deisik

      I have a random heap corruption in my app which is using an external dll that exchanges data with an Internet server

      The crash occurs after an arbitrary amount of time like 2-3 hours up to a couple days

      So the problem is in identifying the command and, most importantly, the module where the heap gets corrupted and what leads to the corruption (not where the error manifests itself) as the issue may well be with the dll, not my code

      Now I'm trying to understand how to use Application Verifier to track down heap corruptions. For demonstration purposes, I delete the same pointer twice and Application Verifier shows me the address of the offending code and the address causing the corruption

      Something like this:

      VERIFIER STOP 0000000000000013: pid 0x19D0: First chance access violation for current stack trace
      
           00000267AD9BD030 : Invalid address causing the exception.
           00007FF734962533 : Code address executing the invalid access.
           000000D98C1289B0 : Exception record.
           000000D98C1284C0 : Context record.
      

      But this is not what I want to know as I can see that in debugger. In this case specifically, I want to know where the memory has been released for the first time (without the advantage of prior knowledge), and, more generally, to learn how to locate the source of heap corruptions, not where they manifest themselves

      I've been trying to follow the steps laid out in this article:
      https://learn.microsoft.com/en-us/windows-hardware/drivers/devtest/application-verifier-debugging-application-verifier-stops

      But the commands related to debugging heap errors simply don't work in the cdb command window in QtCreator, starting with:

      !heap -p
      

      which produces:

      unable to resolve ntdll!RtlpStackTraceDataBase
      unable to read 0000000000000000
      

      So how can I trace this error (and other heap corruption errors) with Application Verifier and cdb in QtCreator?

      deisikD Offline
      deisikD Offline
      deisik
      wrote on last edited by deisik
      #2

      AddressSanitizer is the way to go and debug

      1 Reply Last reply
      0
      • deisikD deisik has marked this topic as solved on

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved