Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. How to find a random nil pointer exception

How to find a random nil pointer exception

Scheduled Pinned Locked Moved Unsolved C++ Gurus
5 Posts 4 Posters 747 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.
  • T Offline
    T Offline
    themts
    wrote on last edited by
    #1

    Hey guys,

    I have a problem and I'm not sure how to solve it quickly.
    I have an application which is running in many productive environments. Very rarely the application is terminating itself with a nil pointer read exception ("... referenced memory at 0x0000000. The memory could not be read.").

    Nobody is able to reproduce the error and nobody can tell me in what situation it is happening. On top of it, it is happening completely random. Sometimes every few hours, sometimes once in a few days.
    I also ran the application with connected debugger for a few days, but I couldn't reproduce it.

    So my question is, is there any way to catch this exception and give me more details where it happened?
    As the application is quite large I cannot put a few catch blocks here and there to see if I get closer.

    I'm using QT 5.12, application compiled with MSVC2017 64bit.

    CU
    mts

    JonBJ raven-worxR 2 Replies Last reply
    0
    • T themts

      Hey guys,

      I have a problem and I'm not sure how to solve it quickly.
      I have an application which is running in many productive environments. Very rarely the application is terminating itself with a nil pointer read exception ("... referenced memory at 0x0000000. The memory could not be read.").

      Nobody is able to reproduce the error and nobody can tell me in what situation it is happening. On top of it, it is happening completely random. Sometimes every few hours, sometimes once in a few days.
      I also ran the application with connected debugger for a few days, but I couldn't reproduce it.

      So my question is, is there any way to catch this exception and give me more details where it happened?
      As the application is quite large I cannot put a few catch blocks here and there to see if I get closer.

      I'm using QT 5.12, application compiled with MSVC2017 64bit.

      CU
      mts

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @themts
      It's very difficult :) It's an MSVC issue.

      I can't remember whether Windows Event Log logs this for you. Try your own null-pointer-exception-crash and see!? Whatever happens you will (likely) need the stack trace, not just the location of the excepting code (e.g. knowing it's in, for the sake of argument, strcpy() won't help you as you don't know where that's called from...).

      I think at one point we did something about generating debug symbols to distribute with release-built code to try to track down if anything happened at a customer site. But we either never used it, or found it was too difficult/useless.

      If you want better answers I think you need to Google for something like "MSVC null pointer release build diagnose", and be prepared to wade through whatever you find!

      1 Reply Last reply
      0
      • fcarneyF Offline
        fcarneyF Offline
        fcarney
        wrote on last edited by
        #3

        I would try and run Heob on your app to see if there are any obvious memory issues. You can use Heob with qt creator in Windows. In Linux you can run valgrind. Search for "Heob Qt" and you should find the page of how to use heob with qt creator.

        C++ is a perfectly valid school of magic.

        T 1 Reply Last reply
        0
        • T themts

          Hey guys,

          I have a problem and I'm not sure how to solve it quickly.
          I have an application which is running in many productive environments. Very rarely the application is terminating itself with a nil pointer read exception ("... referenced memory at 0x0000000. The memory could not be read.").

          Nobody is able to reproduce the error and nobody can tell me in what situation it is happening. On top of it, it is happening completely random. Sometimes every few hours, sometimes once in a few days.
          I also ran the application with connected debugger for a few days, but I couldn't reproduce it.

          So my question is, is there any way to catch this exception and give me more details where it happened?
          As the application is quite large I cannot put a few catch blocks here and there to see if I get closer.

          I'm using QT 5.12, application compiled with MSVC2017 64bit.

          CU
          mts

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          @themts
          probably the easiest and most accurate is to write a minidump the moment the crash occurs and analyze it then afterwards.
          You can either use the native WinAPI (requires some manual bootstrapping of your application) or use Google Breakpad. There are also Qt wrappers for Breakpad on the web.

          But note the minidump in all cases might not be very useful when you try it on a release build without debug symbols of course.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          2
          • fcarneyF fcarney

            I would try and run Heob on your app to see if there are any obvious memory issues. You can use Heob with qt creator in Windows. In Linux you can run valgrind. Search for "Heob Qt" and you should find the page of how to use heob with qt creator.

            T Offline
            T Offline
            themts
            wrote on last edited by
            #5

            @fcarney I will check it out but on the first view it looks like it's only reporting memory leaks and buffer overruns.

            1 Reply Last reply
            0

            • Login

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