stdarg possible bug on powerpc-linux
Daniel Jacobowitz
drow@false.org
Tue Mar 9 19:07:00 GMT 1999
I am not absolutely sure that this is a legitimite problem, because I have
been unable to find a copy of the relevant pieces of the C standard. It
does work on all other platforms I have available to test on, though.
The problem is in calling one function which takes a variable number of
arguments from within another that takes a variable number of
arguments, with the inner function having more than eight arguments.
Running the attached testcase on a powerpc-linux system produces the
following:
Got 1 (0'th)
Got 2 (1'th)
Got 3 (2'th)
Got 4 (3'th)
Got 5 (4'th)
Got 6 (5'th)
Got 7 (6'th)
Got 8 (7'th)
Got 9 (8'th)
Got 10 (9'th)
Got -1
Got 9 (0'th)
Got 10 (1'th)
Got -1 (2'th)
Got 14 (3'th)
Got -1
The outer set of varargs is getting overwritten, and I suspect that other
pieces of the stack are getting clobbered. When there are exactly ten
arguments to func2:
reg = func2(8, 1, 2, 3, 4, 5, 6, 7, 8, -1);
then the problem highlighted by -DREGTEST appears; the overflow_arg_area of
the inner function overlaps the reg_save_area of the outer function.
Because there are more than eight varargs, this clobbers the outer
argument set.
Dan
/--------------------------------\ /--------------------------------\
| Daniel Jacobowitz |__| CMU, CS class of 2002 |
| Debian GNU/Linux Developer __ Part-Time Systems Programmer |
| dan@debian.org | | drow@cs.cmu.edu |
\--------------------------------/ \--------------------------------/
More information about the Gcc-bugs
mailing list