discuss-gnustep
[Top][All Lists]
Advanced

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

Re: problem with gnustep on OpenBSD sparc64


From: Sebastian Reitenbach
Subject: Re: problem with gnustep on OpenBSD sparc64
Date: Thu, 07 Jul 2011 11:09:13 +0200
User-agent: SOGoMail 1.3.7

Hi Wolfgang, 
On Thursday, July 7, 2011 10:56 CEST, Wolfgang Lux <wolfgang.lux@gmail.com> 
wrote: 
 
> Sebastian Reitenbach wrote:
> 
> > I extended the output a bit, to show the address used for size  
> > (a.k.a. context in parse_array)
> >
> > $ ./a.out
> > sizeof_type: before calling parse_array: element_size: 0, size  
> > pointern: 0xfffffffffffcf260
> > parse_array: type: [4i]], context a.k.a. size: 0xfffffffffffcf260
> > sizeof_type: before calling parse_array: element_size: 0, size  
> > pointern: 0xfffffffffffcf0d0
> > parse_array: type: i]], context a.k.a. size: 0xfffffffffffcf0d0
> > sizeof_type: sizeof(typeName): 4 size pointer: 0xfffffffffffcf0d0
> > sizeof_type: size: 32, size pointer: 0xfffffffffffcf0d0
> > parse_array: type: ]]
> > sizeof_type: after calling parse_array: element_size: 0,  
> > element_count: 4, size pointern: 0xfffffffffffcf0d0
> > ^^^ as far as I can see, the value on address 0xfffffffffffcf0d0  
> > should be 32, but I have no idea, why it is not 32???
> > 198                             int element_size = 0;
>                                   ^^^^^
> The problem seems to be here ...
> > (gdb)
> > 200     fprintf(stderr, "sizeof_type: before calling parse_array:  
> > element_size: %i, size pointern: %p\n", element_size, &element_size);
> > (gdb)
> > sizeof_type: before calling parse_array: element_size: 0, size  
> > pointern: 0xfffffffffffe0340
> > 201                             int element_count = parse_array(&t,  
> > (type_parser)sizeof_type, &element_size);
>                                                                               
>                   ^ 
> ^^^^^^^^^^^^^^
> ... and here. The sizeof_type callback expects an argument with type  
> size_t *, but &element_size has type int *. This does work on 32-bit  
> architectures where sizeof(size_t) = sizeof(int) and it works  
> coincidentally on low-endian 64-bit architectures like x86_64, but is  
> definitely wrong for big-endian 64-bit machines like sparc.
> 
> In order to fix, change line 198 to
>    size_t element_size = 0;

this is very well spotted, and indeed seems to be the problem here, after 
making your suggested change I get:
$ ./a.out  
sizeof_type: before calling parse_array: element_size: 0, size pointern: 
0xffffffffffffb828
parse_array: type: [4i]], context a.k.a. size: 0xffffffffffffb828
sizeof_type: before calling parse_array: element_size: 0, size pointern: 
0xffffffffffffb668
parse_array: type: i]], context a.k.a. size: 0xffffffffffffb668
sizeof_type: sizeof(typeName): 4 size pointer: 0xffffffffffffb668
sizeof_type: size: 32, size pointer: 0xffffffffffffb668
parse_array: type: ]]
sizeof_type: after calling parse_array: element_size: 32, element_count: 4, 
size pointern: 0xffffffffffffb668
parse_array: type: ]
sizeof_type: after calling parse_array: element_size: 128, element_count: 3, 
size pointern: 0xffffffffffffb828
48


Sebastian


> 
> Wolfgang
> 
 
 
 
 



reply via email to

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