Mail Archives: cygwin/2002/11/19/02:58:23
I got problem compiling some software and see that some of them core dumps when
calling functions deefined in their code.
Here is a very simple test program.
It runs perfectly as we can expect under AIX.
#include <stdio.h>
int p(char *s);
int main(int argc, char *argv[]) {
int ind = 0 ;
int r = 0 ;
for ( ind = 0 ; ind < argc ; ind++ ) {
printf("%d:%s\n",ind,argv[ind]) ;
}
printf("---------------------------------\n" ) ;
for ( ind = 0 ; ind < argc ; ind++ ) {
char *ptr=argv[ind] ;
printf("%d %d\n",ptr, argv[ind]) ;
printf("%d %d %s\n",ind,sizeof(ptr),ptr) ;
printf("%d %d %s\n",ind,sizeof(argv[0]),ptr) ;
printf("%d %d %s\n",ind,sizeof(int),ptr) ;
r = p(argv[ind]) ;
printf("%d %d %s\n",r,ind,ptr) ;
}
return(0) ;
}
int p(char *s){
printf("dans p:%d %s\n",s,s) ;
return(2);
}
----------------------------------------------
and the result is :
~/tmp $gcc f.c && ./a arg1 arg2 arg3
0:./a
1:arg1
2:arg2
3:arg3
---------------------------------
1633486648 1633486648
0 4 ./a
0 4 ./a
0 4 ./a
4 0 ./a
1633486200 1633486200
1 4 arg1
1 4 arg1
1 4 arg1
4 1 arg1
1633486688 1633486688
2 4 arg2
2 4 arg2
2 4 arg2
4 2 arg2
1633493448 1633493448
3 4 arg3
3 4 arg3
3 4 arg3
4 3 arg3
~/tmp $ gcc -v
Reading specs from /bin/../lib/gcc-lib/i686-pc-cygwin/3.2/specs
Configured with: /netrel/src/gcc-3.2-1/configure --enable-
languages=c,c++,f77,java --enable-libgcj --enable-threads=posix --with-system-
zlib --enable-nls --without-included-gettext --enable-interpreter --disable-
sjlj-exceptions --disable-version-specific-runtime-libs --enable-shared --
build=i686-pc-linux --host=i686-pc-cygwin --target=i686-pc-cygwin --enable-
haifa --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --
includedir=/nonexistent/include --libexecdir=/usr/sbin
Thread model: posix
gcc version 3.2 20020818 (prerelease)
----------------------------------------
Sometimes it coredumps, but this time we can see :
1) the code in p function isn't executed
2) the following printf after the call show a return value (r) incoherent.
I got gcc using setup, it seems to be a prerelease. But I don't belive gcc is
concerned, I surely miss something?
I have no time to investigate.
Some explanation.
----------------------
CHAUVIERE Jean-Raymond
06 80 38 01 14
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -