[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: _Very_ strange problem with compiling



I don't think this is a GCC error because gcc compiles this program
successfully. 

The problem is: you're simply asking for too much stack space.  On my
machine, ulimit -s reports 8129 (that's in Kilobytes).  When I write a
seperate program such as:

#include <stdio.h>

void main(int argc, char **argv)
{
	double a[209677];
	printf("%d\n", sizeof(a)*5/1024);
}

it reports a total usage of 8190K in stack space.  This is obviously
over the limit.  So just increase the stack space and the program runs
fine:  (ulimit -s <size>)

As for the slight difference between the two executables, that's because
you were storing symbols in the executable.  If you run them through
strip there is no difference between the two files.

Peter


On Wed, Mar 07, 2001 at 03:18:56AM +1030, Mark Phillips wrote:
> Hi,
> 
> I thought I'd found a gcc compiler error (and still may have).  The
> following program crashes with a segmentation fault.
> 
> #define N 209677
> 
> int main(int argv, char **argc) {
>   int
>     i;
>   double
>     a[N],
>     b[N],
>     c[N],
>     d[N], 
>     e[N];
> 
>   c[0]=0.0;
>   i=1;
>   c[i]=c[i-1];
> }
> 
> If I make N slightly less, or reduce the number of arrays defined, it
> runs fine.  If I write instead "c[1]=c[0]" it runs fine.  Basically, I
> simplified the original program as much as I could in ways which still
> caused the Seg Fault to happen.
> 
> So I thought this must be a compiler error.  The program was called
> "thick4.c".  I used emacs to paste the file into a new buffer called
> "test.c".  But this one worked fine when I compiled!!!!  The two files
> "thick4.c" and "test.c" are identical, as both diff and cmp prove.
> 
> The executables "thick4" and "test" differ very slightly however.
> 
> -rwxrwxr-x    1 mark     mark         4731 Mar  7 02:53 test*
> -rw-rw-r--    1 mark     mark          162 Mar  7 02:53 test.c
> -rwxrwxr-x    1 mark     mark         4733 Mar  7 02:53 thick4*
> -rw-r--r--    1 mark     mark          162 Mar  7 02:51 thick4.c
> 
> and 
> 
> $ cmp thick4 test  
> thick4 test differ: char 3061, line 2
> 
> Why would identical files compile to slightly different executables?
> I have included gzipped versions of these executables with this email.
> 
> Has anyone got any idea what might be going on?  Or suggestions about
> what I could investigate next!
> 
> Also, can anyone else replicate the error I got (using thick4.c as
> your file name).
> 
> Thanks,
> 
> Mark.
> 
> -- 
> _/~~~~~~~~\___/~~~~~~\____________________________________________________
> ____/~~\_____/~~\__/~~\__________________________Mark_Phillips____________
> ____/~~\_____/~~\________________________________mark@ist.flinders.edu.au_
> ____/~~\HE___/~~\__/~~\APTAIN_____________________________________________
> ____/~~\______/~~~~~~\____________________________________________________
> __________________________________________________________________________
>         "They told me I was gullible ... and I believed them!" 
> 


> ???:test?X[lTE??{
> 
> ????F%?Dm??Z?^???\?+?@<lwO?kv?lv???%?H??C?SL?h?l??>TJD?%?h0*	&????D?!???3g???$???4?3????????K??i????c~F????
?[?E{?y???e?PFyu?5?:??:e?(/C}??i2??P&}V/??m2?e????b
> ?)?(?>)????????^K9Pd??
????x*?7???*????zv<.}?%???F?uE?Up+S??)???w ?F??m?;???e#2??????d??-??%??Ls(i????8??0?Mc#Q+c
????13??e?S?63{w????\???F*R????RM??????l5??7?O|????^??>_L???/?????N???q*??	*?????\??????????????A??Bc?g????Fq?1????z?Q???"?:?9F?+?9&1??@"??????
> ?o?
> ?????1?~lOl????}???????-?8:????1??R??????)??/??EQ??_A?QV<?[
> ?Y???????????Z?za?\
)?#?????YQ~pJ(4????Ob?\??r???w?y???;:??=>?sG????M?{4x???1?[j?$?????ck??
c?pQ_tqm??????9J_|??9l???S7?/?/??,<T?]???U???6???s??U,????DD?????o(??[N)??????#?M?k??>k?q????X?FIqB?%??ERo????2;4???y\1v;???z%?^&K??nC;?j?X~C?t?/???z0???b}??x?~?5??????h????T?
}??????]???[?????????I'<????2???)?nif?l?2::{?u?C????1fD??(J'???T?x??d?v???e??1d;??N8?s???Xy??r;v????Z1??2#???,?E????p2?p?h??;??R?0??i
??#~????&?,?y???sR?g?L??F^??<??&??Q???????#?b?RWc????H<??i?U????as???&??\?>?qJu??6???j?Ry??^?'V????	?????a?O????????i????o]?=?????ok???????%??+?{????h/l???*vO0o?o??E????<?&????W?^Qxt&%??;?[]???????w^??-x????U?K?}???{?.??5
> ???a????V?\?"?~?????>Wt(o???V?a"?????W?? m??+??????s???uZ??&??????????*???h?`\_?h?XXn*aa!T??;?%,????~q???*??L???J?_?8vJx!?S%???K%,V0????9?[?K8>0???'JXD[??8??p#??%,v??^.?O?xE????~~Q??
> ?????k?^Wp?&u|.?*?w+?:?V???"?7Ht???-e??k?7??"?????A???Z8H?R?#?+??6??c????S
> ~?????=?}
???|?G??|?`??JG?'{m#??w?y?X???????D?W?2?i???4o?4`?,???????+?x????F??-Z??????z???y????????????V?????x`?'5o>???7+?{W????,pH????a/(??????'@?C?H??;O:?????	????,~??d???4",m??gkwh?n?????w0i'??m?????=N???e?sy?5????4;?=?;?Dw53?K&2{?)+?--L??E+??du??D,??M~?3?.??j0?????nN?V??@??u0'????{?????n???`??=?L~??????/?h??[??|?W?+@U?i???NkZb?=};;;??????Cf???/?Y???????Q?o???>^?{


-- 
Peter D. Kovacs <peter@kovax.org>
Software Developer
Webmachines, Inc. http://webmachines.com



Reply to: