unknown seg fault reason.

This is a discussion on unknown seg fault reason. within the C Programming forums, part of the General Programming Boards category; if memory overrun occures - in the first example it may corrupt only name pointer, in the second - both ...

  1. #16
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,473
    if memory overrun occures - in the first example it may corrupt only name pointer, in the second - both name and guild pointer, so acessing the guild pointer in the second example in the same scenario will cause the crash, while the first one will survive a little longer
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  2. #17
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    And a typical case of Undefined Behaviour - just as the name implies, it's not defined, so "anything" can happen. As vart says, re-arranging the structure may cause different behaviour, since the data being overwritten is not quite as sensitive as other data being overwritten - e.g. an integer can have just about any value, but pointers need to contain valid memory addresses.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. unknown seg fault after malloc
    By seaking1 in forum C Programming
    Replies: 4
    Last Post: 02-25-2009, 06:51 PM
  2. Getting a seg fault
    By ammochck21 in forum C Programming
    Replies: 11
    Last Post: 01-23-2009, 04:27 AM
  3. seg fault
    By hka26 in forum C++ Programming
    Replies: 1
    Last Post: 10-08-2007, 01:38 AM
  4. Seg Fault Problem
    By ChazWest in forum C++ Programming
    Replies: 2
    Last Post: 04-18-2002, 03:24 PM
  5. seg fault on unix platform
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 12-08-2001, 11:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21