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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:50:16+00:00 2026-05-30T21:50:16+00:00

In some of our code; we are getting a segmentation fault and the gdb

  • 0

In some of our code; we are getting a segmentation fault and the gdb stacktrace shows the pointer is pointing to 0x1. We have 3 instances of these segmentation faults and in each one; the pointer ends up pointing to 0x1.

I would like to recover ‘gracefully’ from this error; instead of SEGFAULT. I can’t check for NULL; since that would be 0. Do I explicitly check for address 0x1?

This is on Linux using GCC3.4.2 (SLES9 machine)

  • 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-30T21:50:17+00:00Added an answer on May 30, 2026 at 9:50 pm

    I would like to recover ‘gracefully’ from this error instead of SEGFAULT. I can’t check for NULL since that would be 0. Do I explicitly check for address 0x1?

    Probably not the best idea.

    The way to recover (technically, recovery is not plausible, you really need to prevent it instead) would be to assume that 0x1 is as bad as NULL and not try to use it in that case, something like:

    if ((p == 0) || (p == 0x1))
        return;
    // Otherwise use p.
    

    However, I hesitate greatly in calling that graceful. The right thing to do is track down what’s causing the pointer to be set to that invalid value and fix it. That’s particularly apt since a piece of code dodgy enough to generate a pointer value of 1 would probably also be dodgy enough to generate 2, or any other non-valid pointer.

    Checking against 1 is akin to stopping headaches with a painkiller when someone’s continuously smacking you in the head. You could take that tablet to ease the headache but surely it would be better to fix the root cause of the problem (i.e., stop the person smacking you in the head).

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

Sidebar

Related Questions

I noticed for a while now the following syntax in some of our code:
I just saw some code in our code base (and it's OLD code, as
Last evening I did some housekeeping on our code repository - basically moved the
My company (EU-based) is considering to release some parts of our code under a
I'm updating some of our legacy C++ code to use the MFC feature pack
I remember few weeks ago when I reorgnized our code and created some namespaces
There's some code in our project that looks a bit like this: Private Sub
Looking at our codebase some code is included in a project explicitly and is
I am fixing some printing (plotter) problems in our java code(windows 32). The paper
Our team is currently using some ported code from an old architecture to a

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.