Thread: unknown seg fault reason.

  1. #16
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Rishon LeZion, Israel
    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
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    David J. Wheeler

  2. #17
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    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.

    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.

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, 07:51 PM
  2. Getting a seg fault
    By ammochck21 in forum C Programming
    Replies: 11
    Last Post: 01-23-2009, 05: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, 12:04 PM