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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:17:15+00:00 2026-06-08T01:17:15+00:00

I encountered my first Segmentation Fault today (newbie programmer). After reading up on what

  • 0

I encountered my first Segmentation Fault today (newbie programmer). After reading up on what a segmentation fault is (Thanks for all of the helpful info on this site, as well as Wikipedia’s lengthy explanation), I’m trying to determine the easiest way to go about finding where my fault is occuring. It’s written in C and the error is occuring on a *NIX based system (I’m not sure which one to be honest… 99% sure it’s Linux). I can’t exactly post my code as I have numerous files that I’m compiling that are all quite lengthy. I was just hoping for some best practices you have all observed. Thanks for your help.

P.s. I’m thinking the error is coming from dereferencing a NULL pointer or using an uninitialized pointer. However, I could definitely be wrong.

  • 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-08T01:17:19+00:00Added an answer on June 8, 2026 at 1:17 am

    Use a debugger, such as gdb or if this is not applicable a strace tool to get a better insight into where the segfault occurs.

    If you use gcc, make sure you compile with -g switch to include debugging information. Then, gdb will show you the exact location in a source code where it segfaults.

    For example, if we have this obvious segfaulty program:

    new.c

    #include <stdio.h>
    
    int main()
    {
            int *i = 0x478734;
            printf("%d", *i);
    }
    

    We compile it with gcc -g new.c -o new and then run the gdb session with gdb new:

    We issue the run command in the interactive session and the else is clear:

    (gdb) run
    Starting program: /home/Tibor/so/new
    [New Thread 9596.0x16a0]
    [New Thread 9596.0x1de4]
    
    Program received signal SIGSEGV, Segmentation fault.
    0x0040118a in main () at new.c:6
    6               printf("%d", *i);
    (gdb)
    

    As DasMoeh and netcoder have pointed out, when segfault has occured, you can use the backtrace command in the interactive session to print a call stack. This can aid in further pinpointing the location of a segfault.

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

Sidebar

Related Questions

This was the first time I encountered this kind of error after dealing with
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
First of all, is this possible? If so: What challenges would I encounter in
Please help check the following code: running it on linux encountered segmentation fault. #deinf
First time I've encountered this T_ECHO error.. function cart($items, $args) { $items .= '<li
I have this weird situation that i have encountered for the first time and
This is my first Android app and I've encountered an exception when trying to
I've encountered something very strange, and things just don't add up. First of all,
I first encountered the concept of lazy registration the Ajax Patterns site, where they
Somehow this is the first time I've ever encountered this problem in many years

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.