Topic
2 replies Latest Post - ‏2011-03-25T21:43:15Z by CarlBurch
CarlBurch
CarlBurch
2 Posts
ACCEPTED ANSWER

Pinned topic Is there a way for AIX to give an address violation on dereferencing NULL?

‏2011-03-15T22:55:53Z |
Is there a way for AIX to give an address violation on dereferencing NULL? Every other Unix/Linux system we support (e.g., Linux, True64, IRIX, Solaris, HP-UX (with a linker option on older versions)) will give a SIGSEGV if you try to load from page zero, while AIX only seems to do so only for stores to it. This makes NULL pointer use hard to debug on AIX. Have I missed a compiler/linker option?

Thanks in advance,

  • Carl Burch
Updated on 2011-03-25T21:43:15Z at 2011-03-25T21:43:15Z by CarlBurch
  • TRB
    TRB
    17 Posts
    ACCEPTED ANSWER

    Re: Is there a way for AIX to give an address violation on dereferencing NULL?

    ‏2011-03-25T17:49:34Z  in response to CarlBurch
    Assuming you are using AIX's C compiler, the man page shows this
    compiler option which may be what you need.

    -qcheck=<suboptions_list> | -qnocheck
    Generates code that performs certain types of
    runtime checking. If a violation is encountered, a
    runtime exception is raised by sending a SIGTRAP
    signal to the process. <suboptions_list> is a
    colon-separated list of one or more of the
    following:

    all
    Enables all suboptions.
    bounds | nobounds
    Performs runtime checking of addresses when
    subscripting within an object of known size.
    divzero | nodivzero
    Performs runtime checking of integer division.
    A trap will occur if an attempt is made to
    divide by zero.
    nullptr | nonullptr
    Performs runtime checking of addresses
    contained in pointer variables used to
    reference storage.

    Specifying -qcheck with no suboptions is equivalent
    to -qcheck=all.

    Default: -qnocheck

    -tony
    • CarlBurch
      CarlBurch
      2 Posts
      ACCEPTED ANSWER

      Re: Is there a way for AIX to give an address violation on dereferencing NULL?

      ‏2011-03-25T21:43:15Z  in response to TRB
      Hi Tony-

      Thanks for the reply, but we're a Gnu shop and not likely to change compilers over this issue. Is there a linker or kernel-based solution?

      • Carl Burch