guile-user
[Top][All Lists]
Advanced

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

Re: Wrong guile-bytestructures description for gnunet progress-info stru


From: Taylan Ulrich Bayırlı/Kammer
Subject: Re: Wrong guile-bytestructures description for gnunet progress-info struct with unions
Date: Mon, 08 Jan 2018 00:40:01 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux)

Amirouche Boubekki <address@hidden> writes:

>> If both of those are correct, further possibilities would be:
>>
>> - Some or all of the structs in the C code are "packed".
>>
>> - There's a bug in bytestructures.
>>
>> To rule out these two, you can use a simple test case: write a tiny C
>> lib with a function that allocates a GNUNET_FS_ProgressInfo struct,
>> writes to its status field, and returns a pointer to it.  Load the lib
>> from Scheme, call the function through FFI... you know the rest; see if
>> you get the correct value when you read the status field from Scheme.
>
> I get the wrong result.
>
> FWIW, you can reproduce following those steps:
>
> $ git clone git://gnunet.org/gnunet-guile2.git
> $ cd gnunet-guile2
> $ guix package -f guix.scm
> $ ./bootstrap && ./configure
> $ c99
> -I/gnu/store/nfaljkxhj0hgxkzxbd4pgmm70h9niq7q-gnunet-git-0.10.1-2.477e0de/include/gnunet/
> -c example.c -o libexample.o && gcc -shared libexample.o -o 
> libexample.so
> $ ./pre-inst-env guile example.scm
>
> The expected output is 42.

FYI I had to change the compilation line to:
c99 \
-I/gnu/store/47lg7wvn6f93wgz0fc6r856ivwlqhc4q-libgpg-error-1.27/include \
-I/gnu/store/qfzl5frp52wdz1vbdj958sz35yfl94xi-libgcrypt-1.8.1/include \
-I/gnu/store/bqljsvafwrmizxf6wkb9m3ppq3f01cr1-gnunet-git-0.10.1-2.477e0de/include/gnunet
 \
-c example.c -o libexample.o &&
gcc -shared libexample.o -o libexample.so

Anyhow, yes I can reproduce the problem.  Further, the size of a
GNUNET_FS_ProgressInfo struct is apparently 152 bytes, whereas the
bytestructure descriptor says 288 bytes.

This seems to be a bug in the alignment calculation for unions.  I think
I fixed it now.

It's just amazing that this bug was discovered on the same day I made my
1.0.0 release. :-D

Aaand 1.0.1 released!

Taylan



reply via email to

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