Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#1191 closed Defect (fixed)

Immediate Segmentation Fault with library after init under linux - Stacksize

Reported by: tstrunk Owned by: davea
Priority: Critical Milestone: Undetermined
Component: BOINC - API Version: 7.0.25
Keywords: 25659 Cc:

Description

When building an application with the current boinc api lib and running it live (that is with shared mem), the timer thread segfaults on Ubuntu 11.10.

The culprit is the timer thread, which dies after TIMER_PERIOD seconds are over (first time timer_handler is called). I think the problem is that the child thread exhausts its stacksize. I can attribute the crash to this changeset (25659): http://boinc.berkeley.edu/trac/changeset/25659/boinc/trunk/boinc/api/boinc_api.cpp

On Ubuntu MAXPATHLEN is 4096. Setting any of the fields changed in the changeset to MAXPATHLEN will produce a segfault. Even raising only abspath[1024] to abspath[3096] produces said segfault.

I'd like to increase the threads stacksize in valgrind, but you can only increase the main thread stacksize there, not the childs. This is one of the error messages: ==24957== Can't extend stack to 0x40273c0 during signal delivery for thread 2: ==24957== too small or bad protection modes

This is the test application, it inits and then sleeps forever and either segfaults or doesn't, depending on MAXPATHLEN.

#include <iostream>
#include <diagnostics.h>
#include <boinc_api.h>
int main(int argc, const char* argv [])
{
    boinc_init_diagnostics( BOINC_DIAG_TRACETOSTDERR|BOINC_DIAG_HEAPCHECKENABLED);
    int rc = boinc_init();
    for (unsigned int i = 0; i < 10000 ;)
    {
        sleep(3000);
    }
}

Change History (3)

comment:1 Changed 12 years ago by tstrunk

Revision [25659] might have been the wrong one. Although I do not get any errors anymore with the testcode, when reverting it, I get a similar valgrind errors, with our complete binary.

comment:2 Changed 12 years ago by davea

Resolution: fixed
Status: newclosed

(In [25781]) - API, Linux: increase timer thread stack size from 16K to 32K.

Apparently new use of MAXPATHLEN can cause overflow. Fixes #1191

comment:3 Changed 12 years ago by tstrunk

This fixed all the crashes I was experiencing. Thanks!

Note: See TracTickets for help on using tickets.