This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Bug with gcc version egcs-2.90.29 980515 (egcs-1.0.3 release) / IRIX 6.3
- To: egcs-bugs at cygnus dot com
- Subject: Bug with gcc version egcs-2.90.29 980515 (egcs-1.0.3 release) / IRIX 6.3
- From: Remi Lehn <Remi dot Lehn at irin dot univ-nantes dot fr>
- Date: Mon, 15 Jun 1998 17:51:35 +0200
- Organization: IRESTE
Hi,
I think there is a bug with gcc version egcs-2.90.29 980515
(egcs-1.0.3 release) under Irix 6.3 when passing the fourth argument
to the semctl() syscall, using the n32 abi. Here's a sample code
(test-semctl.c) :
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
int main() {
int semid;
ushort array[25];
int i;
union semun semun;
semid = semget( 0x200, 10, IPC_CREAT | 0666 );
if ( semid == -1 ) {
perror( "semget()" );
exit(1);
}
for( i = 0; i < 10; i++ )
array[i] = 1;
semun.array = &array[0];
if ( semctl( semid, 0, SETALL, semun ) == -1 ) {
perror( "semctl( semid, 0, SETALL, semun )" );
exit(1);
}
if ( semctl( semid, 0, IPC_RMID, semun ) == -1 ) {
perror( "semctl( semid, 0, IPC_RMID, semun )" );
exit(1);
}
return 0;
}
-----------------------
This program creates a set of 10 semaphores, set all of them to the
value 1 and kill them.
$ egcs-1.0.3a/src/config.guess
mips-sgi-irix6.3
$ gcc -v
Reading specs from
/usr/local/lib/gcc-lib/mips-sgi-irix6.3/egcs-2.90.29/specs
gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)
$ gcc -o test-semctl test-semctl.c
$ ./test-semctl
semctl( semid, 0, SETALL, semun ): Bad address
$ par -s -SS -N semctl test-semctl
semctl( semid, 0, SETALL, semun ): Bad address
0mS was sent signal SIGUSR1
1mS received signal SIGUSR1
19mS semctl(361, 0, SETALL, 0) errno = 14 (Bad address)
semsys : 1 times
Normally, the fourth argument of semctl() should be the base address
of my array, which is correctly passed using the Irix MipsPro C
Compiler :
$ cc -n32 -o test-semctl test-semctl.c
$ ./test-semctl
$ par -s -SS -N semctl test-semctl
0mS was sent signal SIGUSR1
2mS received signal SIGUSR1
18mS semctl(381, 0, SETALL, 0x7fff2ec8) = 0
18mS semctl(381, 0, IPC_RMID, 0x7fff2ec8) = 0
semsys : 2 times
I tried many things to have semctl() being passed anything as its
fourth argument, everything failed (with or without having an explicit
declaration of semctl(), passing directly the address of the array,
without using the union....). Every time, the fourth argument is set
to 0.
There is exactly the same behavior using gcc 2.8.1.
Is there something specific of passing arguments with variable length
argument lists (semctl() has the prototype :
int semctl( int semid, int semnum, int cmd, ... )
) with the n32 abi of irix ? (printf() has a strange behavior too when
missing an explicit declaration; the program :
int main() {
double f = 1000.0;
printf( "%f\n", f );
return 0;
}
prints 0.000000 !)
Thanks for any help,
Remi.