CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2002
    Posts
    35

    segfault from C stack overflow

    Hi All,
    I have made an web application using perl/cgi ,R and C. It processess huge chunk of data.
    Now when the data size is too big . I am getting this error
    Error: segfault from C stack overflow
    There were 18 warnings (use warnings() to see them)
    Error: C stack usage is too close to the limit
    Execution halted


    Can you please suggest how to overcome this problem or how to increase the stack size.
    Any suggestion will be a help as I have no clue.

    thanks in advance

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: segfault from C stack overflow

    Quote Originally Posted by vidhu
    Any suggestion will be a help as I have no clue.
    thanks in advance
    If you're making recursive calls, make them iterative, not recursive.

    If you're declaring large local variables, either make them global or create them dynamically.

    If you're making too many levels of function calls, review your design.

    Increasing the stack should not be an option until you discover exactly why you get the stack overflow, and then you should attempt to remedy the problem programatically.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Apr 2002
    Posts
    35

    Re: segfault from C stack overflow

    Thanks for the reply.
    I cannot change the code as It is internally calling one of the functions of R BioHMM library
    and I am getting the error from the function called

  4. #4
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Seattle, WA
    Posts
    10,895

    Re: segfault from C stack overflow

    Don't be so quick to assume the problem isn't your fault. Just because the actual error happens in 3rd-party code doesn't mean yours isn't responsible.

    If, for instance, your own code used up all the stack space and this other call put it over the edge, that would be your problem.

  5. #5
    Join Date
    Jul 2007
    Posts
    38

    Re: segfault from C stack overflow

    Quote Originally Posted by Paul McKenzie
    Increasing the stack should not be an option until you discover exactly why you get the stack overflow, and then you should attempt to remedy the problem programatically.
    Wondering how can we increase the stack size assigned to our program?
    Regards
    sris kanagasabai

  6. #6
    Join Date
    Apr 1999
    Posts
    27,449

    Re: segfault from C stack overflow

    Quote Originally Posted by vidhu
    Thanks for the reply.
    I cannot change the code as It is internally calling one of the functions of R BioHMM library
    and I am getting the error from the function called
    See this code:
    Code:
    int main()
    {
       double x[10000000];
       CallThirdParty(x);
    }
    What if declaring the array x used up all of the stack, and just calling the third party code creates the error? The fault is yours, not the third-party code.

    Regards,

    Paul McKenzie

  7. #7
    Join Date
    Aug 2005
    Location
    San Diego, CA
    Posts
    1,054

    Re: segfault from C stack overflow

    Quote Originally Posted by skanthaverl
    Wondering how can we increase the stack size assigned to our program?
    Read the compiler documentation. Different compilers and operating systems will have different methods of configuring the application. I'm not suggesting you do that, but there is no C++ answer to that question. It requires extensive knowledge of the system you are writing the program for, especially if it is an embedded application.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured