On Fri, Jan 27, 2017 at 09:09:14AM +0000, Richard W.M. Jones wrote:
I pushed gperf 3.1 to Rawhide.
This changes the type of one of the parameters of the generated
perfect hash function:
-char *in_word_set (register const char *str, register unsigned int len);
+char *in_word_set (register const char *str, register size_t len);
If you have the function prototyped in another file, then you have to
be careful that the prototype exactly matches the new type. Otherwise
on 64 bit architectures you'll end up passing an incorrectly sized
'len' argument (unsigned int == 32 bits vs size_t == 64 bits) which
will subtly break in certain circumstances (but on little endian it'll
still work most of the time, making this bug rather insidious).
Using the functions (third) section of the gperf file can avoid
needing to prototype the function elsewhere, since you can drop a
wrapper of your own choosing into the functions section.
There was a bit of fallout from this change. Mainly it broke
systemd, although there was already a fix upstream.
If you're wondering how to fix this, here are two approaches you can
take.
Firstly the systemd fix which involves sensing the function signature
at ./configure time and adjusting the prototype:
https://github.com/systemd/systemd/commit/c9f7b4d356a453a01aa77a6bb74ca7e...
Alternately, this is the approach I took for libguestfs. Move all
calls to the hash function into the functions (third) section of the
gperf source file, so no explicit prototype is needed:
https://github.com/libguestfs/libguestfs/commit/004de6cf45cfe66ca166cbdcb...
https://github.com/libguestfs/libguestfs/commit/48d4117789e92489b9a3c6f34...
Hope that helps others who have gperf problems. You can also follow
up here if you don't know how to fix it for a particular package and
I'll see if I can help.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-top is 'top' for virtual machines. Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://people.redhat.com/~rjones/virt-top