DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Shivani Joshi Guest

    Segmentation Fault.


    Hello everyone,

    When running a program compiled from C++ source on a Unix Server (Sun OS
    5.7) I get a Segmentation Fault and Core Dump.

    Can anyone advise as to what I should be looking for in the core-dump to
    help me track down the problem.

    Thanks!

    S.J.

  2. #2
    Danny Kalev Guest

    Re: Segmentation Fault.

    Most likely, it's a memory related bug. Look for uninitialized pointers,
    writing past the end of a buffer, etc.

    Danny

    Shivani Joshi wrote:
    >
    > Hello everyone,
    >
    > When running a program compiled from C++ source on a Unix Server (Sun OS
    > 5.7) I get a Segmentation Fault and Core Dump.
    >
    > Can anyone advise as to what I should be looking for in the core-dump to
    > help me track down the problem.
    >
    > Thanks!
    >
    > S.J.


  3. #3
    Harish Guest

    Re: Segmentation Fault.


    First of all try and get the stack trace for the exception and then look for
    the specific function which caused the core dump. There you would get an
    idea as to whether it was your code or was it the system which actually access
    violated. Generally as Danny rightly pointed out, they are due to Uninitialized/Corrputed
    pointer values.

    rgds,
    Harish.



    Danny Kalev <dannykk@inter.net.il> wrote:
    >Most likely, it's a memory related bug. Look for uninitialized pointers,
    >writing past the end of a buffer, etc.
    >
    >Danny
    >
    >Shivani Joshi wrote:
    >>
    >> Hello everyone,
    >>
    >> When running a program compiled from C++ source on a Unix Server (Sun

    OS
    >> 5.7) I get a Segmentation Fault and Core Dump.
    >>
    >> Can anyone advise as to what I should be looking for in the core-dump

    to
    >> help me track down the problem.
    >>
    >> Thanks!
    >>
    >> S.J.



  4. #4
    tns Guest

    Re: Segmentation Fault.


    One possibility of getting a segmentation fault is with char * declrations.
    When you don't initialize it or exceed the limit of '\0' at the length of
    the char * then you get a core dump.
    If you are using char * then initialize it like
    char * xyz = new char(1);
    You can always assign string of any length using strcpy() function.

    Dangling pointers are a major source for segmentation fault.

    If you use gdb then you get the pin-point as to where your program gives
    us a problem.

    >When running a program compiled from C++ source on a Unix Server (Sun OS
    >5.7) I get a Segmentation Fault and Core Dump.
    >
    >Can anyone advise as to what I should be looking for in the core-dump to
    >help me track down the problem.
    >




  5. #5
    Shivani Joshi Guest

    Re: Segmentation Fault.


    Thanks everyone for helping!

  6. #6
    Naveen Philip Guest

    Re: Segmentation Fault.


    Hello
    Shivani
    The already existing answers will help you but I can show you one more place
    were segmentation fault can occur in unix it is when you try to defference
    a null pointer.
    eg)char* name = NULL;
    /*LATER IN YOUR PROGRAM*/
    *name;


    "Shivani Joshi" <shivjoshi@hotmail.com> wrote:
    >
    >Hello everyone,
    >
    >When running a program compiled from C++ source on a Unix Server (Sun OS
    >5.7) I get a Segmentation Fault and Core Dump.
    >
    >Can anyone advise as to what I should be looking for in the core-dump to
    >help me track down the problem.
    >
    >Thanks!
    >
    >S.J.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links