🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #6229

signal/sigcontext problem with HPUX 9.0.5/GCC 2.7.1

#6229
From: Ning Zhang
Date: Tue, 16 Jan 1996 00:00
96 lines
2320 bytes
I have a problem with a simple test program compiled by GCC 2.7.1 on HPUX 9.0.5.
The problem is that the r3 value stored in the sigcontext structure passed to a
signal handler is not correct. However, when the program is running under xdb
or gdb, the value is OK. This program works find if compiled with HPC.

It seems to me that something very strange happened there. If the following
test program compiled with HPC, it runs OK both with and without gdb/xdb.
If it is compiled with GCC, it runs OK under gdb/xdb, i.e. sc_gr3 is the same
as the one obtained by calling GetR3(); if it runs without gdb/xdb,
sc_gr3 is garbage.

Is this a bug with GCC or simply the HPUX kernel?

Here is the test program (getr3.s and testr3.c):

=====================
getr3.s
=====================
	.CODE
GetR3
	.PROC
	.CALLINFO	NO_CALLS
	.ENTRY
	bv		0(2)
	.EXIT
   	copy		3,28
	.PROCEND
	.EXPORT		GetR3
	.END
=====================
testr3.c
=====================
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>

int	  r3;

void
SigHandlerUSR1(sig, code, scp, addr)
	int	  sig, code, addr;
	struct sigcontext * scp;
{
	fprintf(stderr, "INIT R3 = 0x%x USR1 R3 = 0x%x\n", r3, scp->sc_gr3);
	fflush(stderr);

	if( (r3 != 0) && (scp->sc_gr3 != r3) )
	{
		int i = 1;

		/* force an infinite loop */

		while(i);
	}

	fflush(stderr);

} /* SigHandlerUSR1(... */

main()
{
	struct sigvec	  osv;
	struct sigvec	  sv;

	memset((char *) (&sv), 0, sizeof(sv));
	sv.sv_handler = SigHandlerUSR1;
	sv.sv_flags = 0;

	if( sigvector(SIGUSR1, &sv, &osv) != 0 )
	{
		perror("sigvec");
		exit(-1);
	}

	/*
	 * generate signal SIGUSR1
	 */
	KillThisProc(SIGUSR1);

} /* main(... */

KillThisProc(sig)
	int	  sig;
{
	int	  i;

	r3 = GetR3();

	kill(getpid(), sig);

	for( i = 0; i < 0x7FFFFF; i++ )
	{
		i = i;
	}
	return(0);
}
Technical Details
Message-ID: <4dfdfn$jc9@virtech.aib.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113d02,4c68a4136e50337,start
X-Google-Attributes: gid113d02,public
From: zhang@aib.COM (Ning Zhang)
Subject: signal/sigcontext problem with HPUX 9.0.5/GCC 2.7.1
Date: 1996/01/16
Message-ID: <4dfdfn$jc9@virtech.aib.com>
X-Deja-AN: 135561311
distribution: gnu
sender: daemon@cis.ohio-state.edu
organization: AIB Software Corporation
newsgroups: gnu.gcc.bug