Help me debug?

  • Aggressive
  • Amazed
  • Amused
  • Angelic
  • Angry
  • Artistic
  • Asleep
  • Bashful
  • Blah
  • Bored
  • Breezy
  • Brooding
  • Busy
  • Buzzed
  • Chatty
  • Cheeky
  • Cheerful
  • Cloud 9
  • Cold
  • Cold Turkey
  • Confused
  • Cool
  • Crappy
  • Curious
  • Cynical
  • Daring
  • Dead
  • Depressed
  • Devilish
  • Doh
  • Doubtful
  • Drunk
  • Energetic
  • Fiendish
  • Fine
  • Flirty
  • Gloomy
  • Goofy
  • Grumpy
  • Happy
  • Hot
  • Hung Over
  • In Love
  • In Pain
  • Innocent
  • Inspired
  • Lonely
  • Lurking
  • Mellow
  • Mischievious
  • Nerdy
  • None
  • Not Worthy
  • Paranoid
  • Pensive
  • Psychedelic
  • Question
  • Relaxed
  • ROFLMAO
  • Sad
  • Scared
  • Shocked
  • Sick
  • Sleepy
  • Sneaky
  • Snobbish
  • Spaced
  • Stressed
  • Sunshine
  • Sweet Tooth
  • Thinking
  • Tired
  • Twisted
  • Vegged Out
  • Worried
  • Yee Haw
  • Results 1 to 15 of 15

    Thread: Help me debug?

    1. #1
      Em7add11's Avatar
      Em7add11 is offline next if /^[\*|\[]/;
      ---
       
      Join Date
      January 27th, 2003
      Location
      Ontario
      Posts
      28,538
      Male - Atheist
      Mentioned
      0 Post(s)

      Help me debug?

      So, I'm working on a program that compiles fine but gives this message when run:

      jfarthing@em7add11 # ./a.out
      Segmentation Fault

      jfarthing@em7add11 #



      Anybody want to offer some advice?
      In the grave they chose to make their beds
      Now all that they've created comes crashing down,
      Down upon their heads
      Death is waiting

    2. #2
      themuzicman's Avatar
      themuzicman is offline Are they flying yet?
      Amused
       
      Join Date
      March 6th, 2003
      Location
      Michigan
      Posts
      39,965
      Male - Christian
      Mentioned
      1 Post(s)

      Re: Help me debug?

      You have a bug in your program.






      OK...

      http://www.cs.bu.edu/help/unix/segmentation_fault.html

      A segmentation fault occurs when your program tries to access memory locations that haven't been allocated for the program's use. canf("%d", number);

      In this case, number is integer. scanf() expects you to pass it the address of the variable you want to read an integer into. But, the writer has fogotten to use the `&' before number to give scanf the address of the variable. If the value of number happened to be 3, scanf() would try to access memory location 3, which is not accessible by normal users. The correct way to access the address of number would be to place a `&' (ampersand) before number:

      scanf("%d", &number);

      Another common segmentation fault occurs when you try to access an array index which is out of range. Let's say you set up an array of integers:

      int integers[80];

      If, in your program, you try to use an index (the number within the brackets) over 79, you will ``step out of your memory bounds'', which causes a segmentation fault. To correct this, rethink your array bounds or the code that is using the array.

      © source where applicable



      Not sure if you're using memory pointers or what, but I think it usually has to do with accessing uninitialized variables or using variables improperly, as in the example above

      Michael
      "... engage your brain before you engage your weapon." - Gen. James Mattis, USMC

      I don't care how systematic your theology is until you show me how biblical it is.

    3. #3
      Em7add11's Avatar
      Em7add11 is offline next if /^[\*|\[]/;
      ---
       
      Join Date
      January 27th, 2003
      Location
      Ontario
      Posts
      28,538
      Male - Atheist
      Mentioned
      0 Post(s)

      Re: Help me debug?

      Here's my source:

      Code:
      #include <stdio.h>
      
      int main() {
          printf("Segmentation Fault\n");
          return 1;
      }
      See anything that resembles what that article describes?
      In the grave they chose to make their beds
      Now all that they've created comes crashing down,
      Down upon their heads
      Death is waiting

    4. #4
      themuzicman's Avatar
      themuzicman is offline Are they flying yet?
      Amused
       
      Join Date
      March 6th, 2003
      Location
      Michigan
      Posts
      39,965
      Male - Christian
      Mentioned
      1 Post(s)

      Re: Help me debug?

      Just the author of the program.

      (Who will now be segmented. DEVELOPERS! oy!)
      "... engage your brain before you engage your weapon." - Gen. James Mattis, USMC

      I don't care how systematic your theology is until you show me how biblical it is.

    5. #5
      Sheepdog's Avatar
      Sheepdog is offline Swindling the next generation.
      Twisted
       
      Join Date
      February 6th, 2003
      Location
      Backyard
      Posts
      12,617
      Male - Christian
      Mentioned
      0 Post(s)

      Re: Help me debug?

      seg faults are evil, evil little errors.
      Living so free is a tragedy
      When you can't be what you want to be
      Living so free is a tragedy
      When you can't see what you need to see
      -- Powerman 5000, "Free"

    6. #6
      $cirisme's Avatar
      $cirisme is offline From another world
      Cool
       
      Join Date
      January 26th, 2003
      Location
      United States
      Posts
      24,215
      Male - Christian
      Mentioned
      0 Post(s)

      Re: Help me debug?

      Quote Originally posted by Em7add11
      Here's my source:

      Code:
      #include <stdio.h>
      
      int main() {
          printf("Segmentation Fault\n");
          return 1;
      }
      See anything that resembles what that article describes?

      Just a note, $cir is right. -Sparko

    7. #7
      lee_merrill's Avatar
      lee_merrill is offline For the Lord is good...
      Spaced
       
      Join Date
      June 20th, 2004
      Location
      North Carolina
      Posts
      6,815
      Male - Christian
      Mentioned
      0 Post(s)

      Re: Help me debug?

      <!-- No comment? -->

      <!-- Actually, this really isn't a comment! -->

      And it's all the segment's fault!

      The BSD demon made me do it...

      Blessings,
      Lee
      "What I pray of you is, to keep your eye upon Him, for that is everything." (J.B. Stoney)

    8. #8
      NeilUnreal's Avatar
      NeilUnreal is offline <-- Carroll Shelby, RIP
      Twisted
       
      Join Date
      April 8th, 2003
      Location
      Mr. Bun-bun's Scullery
      Posts
      8,309
      Male - Christian
      Mentioned
      0 Post(s)

      Re: Help me debug?

      It's like the apocryphal tape backup restore source code:

      Code:
      #include <stdio.h>
      
      int main () 
      {
          printf ("Cannot read tape.");
      
          return -1;
      }
      You can build a prototype by the book, but a legend you build by the seat of your pants.

      -Carroll Shelby

    9. #9
      themuzicman's Avatar
      themuzicman is offline Are they flying yet?
      Amused
       
      Join Date
      March 6th, 2003
      Location
      Michigan
      Posts
      39,965
      Male - Christian
      Mentioned
      1 Post(s)

      Re: Help me debug?

      Code:
      select * from developers where developers = TRUE
      no rows returned
      "... engage your brain before you engage your weapon." - Gen. James Mattis, USMC

      I don't care how systematic your theology is until you show me how biblical it is.

    10. #10
      {Tim}'s Avatar
      {Tim} is offline En Taro Tassadar
      ---
       
      Join Date
      April 26th, 2004
      Posts
      10,651
      Male - †
      Mentioned
      0 Post(s)

      Re: Help me debug?

      Quote Originally posted by NeilUnreal
      It's like the apocryphal tape backup restore source code:

      Code:
      #include <stdio.h>
      
      int main () 
      {
          printf ("Cannot read tape.");
      
          return -1;
      }
      Or my personal favourite... (forgive the BASIC )

      Code:
      PRINT "WARNING! ALL DATA ON NON-REMOVEABLE"
      PRINT "DRIVE C: WILL BE LOST! PROCEED? (Y/N)";
      
      do:loop until InKey$<>""
      
      PRINT "Y"
      PRINT
      PRINT "Formatting..."
      ... erase your hard drives, and your backups too,
      and the hard drives of anyone related to you...
      ~ "Weird Al" Yankovic, Virus Alert

      ... we're not on Earth to be "punished" by sin, we're on Earth to serve God. You don't want to do that?
      Go do whatever suits you and die happy if you can. ~ Vigilante

    11. #11
      NeilUnreal's Avatar
      NeilUnreal is offline <-- Carroll Shelby, RIP
      Twisted
       
      Join Date
      April 8th, 2003
      Location
      Mr. Bun-bun's Scullery
      Posts
      8,309
      Male - Christian
      Mentioned
      0 Post(s)

      Re: Help me debug?

      Quote Originally posted by {Tim}
      Or my personal favourite...


      When you implement a Twain scanner driver, a common place to start is with the Twain default library. One of the fall-back error messages in that library reads something like:

      "Sorry, detailed error status returned success."

      (In other words, it succeeded in returning a fatal error, )

      And I've actually seen it show up at the user interface level from at least one commercial scanner driver.

      -Neil
      You can build a prototype by the book, but a legend you build by the seat of your pants.

      -Carroll Shelby

    12. #12
      lee_merrill's Avatar
      lee_merrill is offline For the Lord is good...
      Spaced
       
      Join Date
      June 20th, 2004
      Location
      North Carolina
      Posts
      6,815
      Male - Christian
      Mentioned
      0 Post(s)

      Re: Help me debug?

      We have a product that says, erm, "Press enter to exit"...

      Blessings,
      Lee
      "What I pray of you is, to keep your eye upon Him, for that is everything." (J.B. Stoney)

    13. #13
      Sheepdog's Avatar
      Sheepdog is offline Swindling the next generation.
      Twisted
       
      Join Date
      February 6th, 2003
      Location
      Backyard
      Posts
      12,617
      Male - Christian
      Mentioned
      0 Post(s)

      Re: Help me debug?

      there'e always the ubiquoitous "Keyboard not found. Press F1 to continue"
      Living so free is a tragedy
      When you can't be what you want to be
      Living so free is a tragedy
      When you can't see what you need to see
      -- Powerman 5000, "Free"

    14. #14
      lee_merrill's Avatar
      lee_merrill is offline For the Lord is good...
      Spaced
       
      Join Date
      June 20th, 2004
      Location
      North Carolina
      Posts
      6,815
      Male - Christian
      Mentioned
      0 Post(s)

      Re: Help me debug?



      Maybe by the F1 button they mean the belly button on the front of the computer?

      Blessings,
      Lee
      "What I pray of you is, to keep your eye upon Him, for that is everything." (J.B. Stoney)

    15. #15
      Barry Desborough's Avatar
      Barry Desborough is offline I don't believe it, whatever it is.
      ---
       
      Join Date
      March 22nd, 2005
      Location
      France, près de Toulouse
      Posts
      2,876
      Male - teapot
      Mentioned
      0 Post(s)

      Re: Help me debug?

      Quote Originally posted by Em7add11
      So, I'm working on a program that compiles fine but gives this message when run:

      jfarthing@em7add11 # ./a.out
      Segmentation Fault

      jfarthing@em7add11 #



      Anybody want to offer some advice?
      You're not null-terminating your string?
      Feedback sought: Please check out Wikidia. Its TWeb thread is here.

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •