Bug 42891 - variable argument list with more than 8 entries, only low 4 bytes are passed
variable argument list with more than 8 entries, only low 4 bytes are passed
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: gcc (Show other bugs)
7.1
ia64 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
David Lawrence
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-05-30 14:02 EDT by Paul Pluzhnikov
Modified: 2007-04-18 12:33 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-05-30 15:05:29 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Paul Pluzhnikov 2001-05-30 14:02:52 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; COM+ 
1.0.2204)

Description of problem:
It appears that __builtin_stdarg_start improperly uses
st4 instead of st8 when spilling out 9th argument

How reproducible:
Always

Steps to Reproduce:
1. Compile program below with 'gcc stdarg.c'
--- cut here --- stdarg.c ---
#include <stdarg.h>
#include <stdio.h>

void func2(int i, va_list args)
{
    void *p;
    printf("%d ---\n", i);
    for (; i; i--) {
        p = va_arg(args, void *);
        printf("%p\n", p);
    }
    printf("\n");
}

void func(int i, ...)
{
    va_list ap;

    va_start(ap, i);
    func2(i, ap);
    va_end(ap);
}

int main(int argc, char *argv[])
{
    int i;
    
    func(9, &i, &i, &i, &i, &i, &i, &i, &i, &i);
    func(8, &i, &i, &i, &i, &i, &i, &i, 0);
    
    return 0;
}
--- cut here --- stdarg.c ---
2. Run it: ./a.out


Actual Results:  
9 ---
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0

8 ---
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000fff00000000

Note that last line has only the low half-word cleared

Expected Results:  
9 ---
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0

8 ---
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
0x80000ffffffff5a0
(nil)

Additional info:

uname -a
Linux angus 2.4.0-0.99.11smp #1 SMP Wed Jan 24 13:38:34 EST 2001 ia64 
unknown

gcc -v
Reading specs from /usr/lib/gcc-lib/ia64-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-84)

cat /etc/issue

Red Hat Linux release 7.0.90 (Fisher)
Kernel 2.4.0-0.99.11smp on an ia64
Comment 1 Bill Nottingham 2001-05-30 15:05:25 EDT
Using NULL instead of 0 to terminate the list avoids this.
Comment 2 Jakub Jelinek 2001-06-01 04:02:01 EDT
This is not a bug, it is a feature of the IA-64 ABI. You have to use proper
types for the arguments matching ..., if it is expecting a pointer, you should
pass a pointer, not integer (so NULL will do and in this case 0L would do as
well).

Note You need to log in before you can comment on or make changes to this bug.