gnustep-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: openbsd macppc clang broken va_args(_, id)


From: David Chisnall
Subject: Re: openbsd macppc clang broken va_args(_, id)
Date: Sat, 17 Oct 2020 18:35:21 +0100

Hi,

The PowerPC back end in clang is probably not well tested with Objective-C.  If 
you have a reduced test case (i.e. something that *doesn’t* include any 
headers), it would be a good idea to file a bug against clang.

The logic for setting up variadic call frames and handling va_arg are 
completely disconnected in clang and so it’s entirely possible that id is 
handled differently in the PowerPC back end.  It’s mostly maintained by IBM 
folks these days and I don’t think Objective-C is something that they’re going 
to be testing regularly.

David

> On 10 Oct 2020, at 22:46, Anthony Richardby <anthonyc@gmx.co.uk> wrote:
> 
> Hi,
> I've been trying to get GNUstep up and running on my powerpc setup for
> a little while, and
> I figure this is the best place to ask for advice, or if anybody knows
> some trick I'm not aware of!
> 
> The problem:
> Using 'va_arg()' with type 'id' just doesn't work, you certainly don't
> get back the arguments to
> the function, at least. For example, consider the following program:
> 
> #include <stdio.h>
> #include <Foundation/Foundation.h>
> 
> id test(id first, ...) {
>        va_list ap;
>        id second, third;
> 
>        va_start(ap, first);
>        second = va_arg(ap, id);
>        third = va_arg(ap, id);
>        return third;
> }
> 
> 
> int main(int argc, char **argv) {
>        NSString *str1 = @"test1";
>        NSString *str2 = @"test2";
>        NSString *str3 = @"test3";
> 
>        id res = test(str3, str2, str3);
>        printf("%x\n", res);
>        if (str3 == res) {
>                printf("works\n");
>        } else {
>                printf("broken\n");
>        }
>        return 0;
> }
> 
> When run, this prints out:
> 
> netty$ ./obj/Hello
> 0
> broken
> 
> And actually, debugging this shows that va_arg is returning the same
> data each for 'second'
> and 'third'.
> 
> Breakpoint 1, test (first=0x382b48f8) at main.m:11
> 11              return third;
> Current language:  auto; currently minimal
> (gdb) p first
> $1 = 0x382b48f8
> (gdb) p second
> $2 = 0x3fe00000
> (gdb) p third
> $3 = 0x0
> (gdb)
> 
> 'second' and 'third' are always 0x3fe00000, and 0x0 on every single
> run.
> 
> Replacing 'va_arg(ap, id)' with 'va_arg(ap, void*)' makes the program
> run as exected.
> Outputing:
> netty$ ./obj/Hello
> 1e5a4910
> works
> 
> For the moment, I've got everything working just by replacing all
> occurrances of 'id' when used with
> va_arg with 'void*'. And everything seems to work just fine. The funny
> thing is, this seems to be
> specific to 'id' - is it given special treatment somehow?
> 
> I'm running OpenBSD 6.7, building from a slightly modified ports tree
> (it's disabled on macppc
> by default) CC/CXX is set to base clang.
> 
> Anyone got ideas what's going on here?
> 
> Cheers,
> Anthony.
> 
> 
> 
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]