Thread: Segmentation fault

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    3

    Segmentation fault

    Hi,

    I am writeing a program to add, multiply and transpose matrix. I use malloc to allocate mem. as per the project, there can not be any mem leak or segmentation fault. but when i compile my program it says segmentation fault. in the programm (code::Blocks) it giving me following msg
    Process terminated with status 1 (0 minutes, 13 seconds)

    can some one help me. Its kind of important Lab that worth a lot.

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Can't help you without the code, except to say that if you compile in debug mode and run it in the debugger, it should crash where the seg fault is occurring, and you can check the values of the variables at the point of the crash. Can help you pinpoint the problem.

  3. #3
    Registered User
    Join Date
    Nov 2010
    Posts
    3
    Quote Originally Posted by rags_to_riches View Post
    Can't help you without the code, except to say that if you compile in debug mode and run it in the debugger, it should crash where the seg fault is occurring, and you can check the values of the variables at the point of the crash. Can help you pinpoint the problem.
    Its a lab, and i canot post that on public forums.

    can some one please help me i am stuck and its due in few hours.

    << snipped email address >>

  4. #4
    Registered User
    Join Date
    Feb 2003
    Posts
    596
    Given that you are manipulating matrices, my first guess would be that somewhere you are overrunning the bounds of some array, but you will have to figure out exactly which line of code is at fault. If you don't know how to use a debugger, your best chance is to put a print statement, e.g.:
    Code:
    printf("didn't crash yet\n");
    halfway through the program, & see if it is printed before it crashes. Just keep moving it around until you pinpoint the error. If you find the line that is at fault & still don't know why, you can post just that line & maybe we can help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. segmentation fault when using command line arguments
    By andres.ordonez in forum C Programming
    Replies: 5
    Last Post: 08-27-2010, 07:54 PM
  2. Segmentation fault
    By bennyandthejets in forum C++ Programming
    Replies: 7
    Last Post: 09-07-2005, 05:04 PM
  3. Segmentation fault
    By NoUse in forum C Programming
    Replies: 4
    Last Post: 03-26-2005, 03:29 PM
  4. Locating A Segmentation Fault
    By Stack Overflow in forum C Programming
    Replies: 12
    Last Post: 12-14-2004, 01:33 PM
  5. Segmentation fault...
    By alvifarooq in forum C++ Programming
    Replies: 14
    Last Post: 09-26-2004, 12:53 PM