Re: [vdr] OT: local variables limited in size to (8*1024*1024-32*1024) bytes ?

2008-11-29 Thread Petri hintukainen
Matthias Schwarzott wrote:
> On Samstag, 29. November 2008, Stefan Lucke wrote:
> > Hi,
> >
> Hi Stefan!
> 
> > the attached program segfaults when using a larger local variable.
> >
> > Depending on used value I get segfaulst at different locations.
> >
> > //#define BUFSIZE (9*1024*1024-16*1024) // only segfault
> > #define BUFSIZE (8*1024*1024-16*1024) // hello + segfault
> > //#define BUFSIZE (8*1024*1024-32*1024) // hello + 2nd line
> >
> > When using last definition of BUFSIZE every thing is fine.
> >
> 
> I guess linux has some limit on the stack-size. Sounds like 8MB in your case.

See man getrlimit, sub-section RLIMIT_STACK.


- Petri


___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


Re: [vdr] OT: local variables limited in size to (8*1024*1024-32*1024) bytes ?

2008-11-29 Thread Matthias Schwarzott
On Samstag, 29. November 2008, Stefan Lucke wrote:
> Hi,
>
Hi Stefan!

> the attached program segfaults when using a larger local variable.
>
> Depending on used value I get segfaulst at different locations.
>
> //#define BUFSIZE (9*1024*1024-16*1024) // only segfault
> #define BUFSIZE (8*1024*1024-16*1024) // hello + segfault
> //#define BUFSIZE (8*1024*1024-32*1024) // hello + 2nd line
>
> When using last definition of BUFSIZE every thing is fine.
>

I guess linux has some limit on the stack-size. Sounds like 8MB in your case.
But why can't you just alloc large data on the heap with malloc as everyone 
else does?

Regards
Matthias

___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr


[vdr] OT: local variables limited in size to (8*1024*1024-32*1024) bytes ?

2008-11-29 Thread Stefan Lucke
Hi,

the attached program segfaults when using a larger local variable.

Depending on used value I get segfaulst at different locations.

//#define BUFSIZE (9*1024*1024-16*1024) // only segfault
#define BUFSIZE (8*1024*1024-16*1024) // hello + segfault
//#define BUFSIZE (8*1024*1024-32*1024) // hello + 2nd line

When using last definition of BUFSIZE every thing is fine.


[EMAIL PROTECTED] /home/nfs/extra/src/video/DVB/xlist $ ./test
Speicherzugriffsfehler
[EMAIL PROTECTED] /home/nfs/extra/src/video/DVB/xlist $ vi test.cc
[EMAIL PROTECTED] /home/nfs/extra/src/video/DVB/xlist $ g++   -g  test.cc   -o 
test
[EMAIL PROTECTED] /home/nfs/extra/src/video/DVB/xlist $ ./test
hello
./test: argc = 1
[EMAIL PROTECTED] /home/nfs/extra/src/video/DVB/xlist $ vi test.cc
[EMAIL PROTECTED] /home/nfs/extra/src/video/DVB/xlist $ g++   -g  test.cc   -o 
test
[EMAIL PROTECTED] /home/nfs/extra/src/video/DVB/xlist $ ./test
hello
Speicherzugriffsfehler
[EMAIL PROTECTED] /home/nfs/extra/src/video/DVB/xlist $ ./test
[EMAIL PROTECTED] /home/nfs/extra/src/video/DVB/xlist $ ulimit
unlimited
[EMAIL PROTECTED] /home/nfs/extra/src/video/DVB/xlist $ gcc --version
gcc (GCC) 4.1.2 (Gentoo 4.1.2 p1.1)
Copyright (C) 2006 Free Software Foundation, Inc.
Dies ist freie Software; die Kopierbedingungen stehen in den Quellen. Es
gibt KEINE Garantie; auch nicht für MARKTGÄNGIGKEIT oder FÜR SPEZIELLE ZWECKE.

-- 
Stefan Lucke
#include 
#include 
#include 
#include 
#include 
#include 
#include 

//XXX #define BUFSIZE 256*1024
//
//#define BUFSIZE 20*1024*1024
//#define BUFSIZE (9*1024*1024-16*1024) // only segfault
#define BUFSIZE (8*1024*1024-16*1024) // hello + segfault
//#define BUFSIZE (8*1024*1024-32*1024) // hello + 2nd line

#define DUMP 1

#ifdef DUMP
#define DBG(expr) expr;
#else
#define DBG(expr) {} 
#endif

typedef unsigned long tPTS;

int main(int argc, char *argv[])
{
fprintf(stderr, "hello\n");
fprintf(stderr, "%s: argc = %d\n", argv[0], argc);
{
unsigned char a [BUFSIZE];
}
return 1;
}
___
vdr mailing list
vdr@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr