Skip to contentSkip to conversation

PROBLEM: large auto variables cause segfault under 2.6

DISCUSSION Andrei A. Voropaev 3 participants 4 messages Oct 5, 2004 – Oct 7, 2004

lore
Share & tools
lore
#0 lore raw

Declaring very large auto variables cause segfaults in the program under 2.6 kernel.

Take a look at this program.

  int main( int argc, char **argv )
  {
       unsigned char  bRet = 0;
       char tst[67123456];
  
  
       const char* pcSupportedParams = "d:t:lV:C:cP:h";
  
       printf("pcSupportedParams = %s\n");
       return 0;

}

When compiled it produces segfault under kernel 2.6.8.1. The problem is with that large array. Under 2.4 kernel the program gets its memory region automatically extended to accomodate for large auto variables. Under 2.6 it gets segment violation signal.

#1 lore raw
Quoted 11 lines · Andrei A. Voropaev

Declaring very large auto variables cause segfaults in the program under 2.6 kernel.

Take a look at this program.

  int main( int argc, char **argv )
  {
       unsigned char  bRet = 0;
       char tst[67123456];

you have a stack variable that is several orders of magnitude bigger than the rlimit you have set for the stack I suspect. Try increasing the stack rlimit...

#2 lore raw
Quoted 10 lines · Arjan van de Ven
Quoted 9 lines · Andrei A. Voropaev

Declaring very large auto variables cause segfaults in the program under 2.6 kernel.

Take a look at this program.

  int main( int argc, char **argv )
  {
       unsigned char  bRet = 0;
Quoted 6 lines
Quoted 2 lines
       char tst[67123456];

you have a stack variable that is several orders of magnitude bigger than the rlimit you have set for the stack I suspect. Try increasing the stack rlimit...

Yep. I was just going to write "excuse me" letter. Looks like under new kernel the kernel stack is limited to 8M while under 2.4 kernel it is unlimited. So setrusage should help us.

Sorry for distractions.

Andrei

#3 lore raw
In reply to Andrei A. Voropaev

Salut,

Quoted 4 lines · Andrei A. Voropaev
  int main( int argc, char **argv )
  {
       unsigned char  bRet = 0;
Quoted 8 lines
       char tst[67123456];
  
  
       const char* pcSupportedParams = "d:t:lV:C:cP:h";
  
       printf("pcSupportedParams = %s\n");
       return 0;

}

It might also crash because your printf is printing something odd.

Tonnerre