After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 328254 - Build breakage (GSlice)
Build breakage (GSlice)
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.9.x
Other All
: Normal major
: ---
Assigned To: Tim Janik
gtkdev
Depends on:
Blocks:
 
 
Reported: 2006-01-23 08:10 UTC by Jens Granseuer
Modified: 2006-01-25 18:23 UTC
See Also:
GNOME target: ---
GNOME version: 2.13/2.14


Attachments
memalign(3) test calls (630 bytes, text/plain)
2006-01-23 15:20 UTC, Tim Janik
  Details
Alternate patch (3.43 KB, patch)
2006-01-25 18:07 UTC, Jens Granseuer
none Details | Review

Description Jens Granseuer 2006-01-23 08:10:18 UTC
Please describe the problem:
make errors out with the following messages

Making all in gobject
make[2]: Entering directory `/usr/src/packages/BUILD/glib-2.9.4/gobject'
source='glib-genmarshal.c' object='glib-genmarshal.o' libtool=no \
depfile='.deps/glib-genmarshal.Po' tmpdepfile='.deps/glib-genmarshal.TPo' \
depmode=gcc /bin/sh ../depcomp \
gcc -DHAVE_CONFIG_H -I. -I. -I.. -DG_LOG_DOMAIN=\"GLib-GObject\" -I.. -I../glib
-I.. -DG_DISABLE_CAST_CHECKS -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS
-DG_DISABLE_DEPRECATED -DGOBJECT_COMPILATION -DG_DISABLE_CONST_RETURNS  -pthread
 -O2 -march=i686 -Wall -c `test -f 'glib-genmarshal.c' || echo
'./'`glib-genmarshal.c
/bin/sh ../libtool --mode=link gcc  -O2 -march=i686 -Wall  -Wl,--as-needed -o
glib-genmarshal  glib-genmarshal.o ../glib/libglib-2.0.la 
mkdir .libs
gcc -O2 -march=i686 -Wall -Wl,--as-needed -o .libs/glib-genmarshal
glib-genmarshal.o  ../glib/.libs/libglib-2.0.so
creating glib-genmarshal
make glib-genmarshal
make[3]: Entering directory `/usr/src/packages/BUILD/glib-2.9.4/gobject'
make[3]: `glib-genmarshal' is up to date.
make[3]: Leaving directory `/usr/src/packages/BUILD/glib-2.9.4/gobject'
echo "#ifndef __G_MARSHAL_H__" > xgen-gmh \
&& echo "#define __G_MARSHAL_H__" >> xgen-gmh \
&& ./glib-genmarshal --nostdinc --prefix=g_cclosure_marshal ./gmarshal.list
--header >> xgen-gmh \
&& echo "#endif /* __G_MARSHAL_H__ */" >> xgen-gmh \
&& (cmp -s xgen-gmh gmarshal.h 2>/dev/null || cp xgen-gmh gmarshal.h) \
&& rm -f xgen-gmh xgen-gmh~ \
&& echo timestamp > stamp-gmarshal.h

***MEMORY-ERROR***: [15477]: GSlice: failed to allocate 120 bytes (alignment:
128): Invalid argument

make[2]: *** [stamp-gmarshal.h] Error 1
make[2]: Leaving directory `/usr/src/packages/BUILD/glib-2.9.4/gobject'

This is with glib 2.9.4 but I've had the same issue with previous 2.9 releases
as well. Not sure if this is even connected to the compiler, but I'm using gcc 2.95.

Steps to reproduce:


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Tim Janik 2006-01-23 15:20:51 UTC
Created attachment 57945 [details]
memalign(3) test calls 

this is essentially memalign(128,120) returning -1, errno=EINVAL when it's supposed to work. i have attached a test program for you to run, it produces this on my machine: 
memalign (  128,   120) = 0x804a080 (errno: Success)
memalign (  256,   248) = 0x804a100 (errno: Success)
memalign (  512,   504) = 0x804a200 (errno: Success)
memalign ( 1024,  1016) = 0x804a400 (errno: Success)
memalign ( 2048,  2040) = 0x804a800 (errno: Success)
memalign ( 4096,  4088) = 0x804b000 (errno: Success)
memalign ( 8192,  8184) = 0x804c000 (errno: Success)
memalign (16384, 16376) = 0x8050000 (errno: Success)
memalign (32768, 32760) = 0x8058000 (errno: Success)
memalign (65536, 65528) = 0x40170000 (errno: Success)

i.e. memalign(128,120) does work here. 

please run it on your machien and provide the results here.
please also provide the exact system you're using by executing:
  $ uname -a
and libc version:
  $ ls -al /lib/libc*
i suppose it's glibc you're using.
Comment 2 Jens Granseuer 2006-01-24 07:45:51 UTC
aligntest works fine:

memalign (  128,   120) = 0x8049800 (errno: Success)
memalign (  256,   248) = 0x8049900 (errno: Success)
memalign (  512,   504) = 0x8049a00 (errno: Success)
memalign ( 1024,  1016) = 0x8049c00 (errno: Success)
memalign ( 2048,  2040) = 0x804a000 (errno: Success)
memalign ( 4096,  4088) = 0x804b000 (errno: Success)
memalign ( 8192,  8184) = 0x804c000 (errno: Success)
memalign (16384, 16376) = 0x8050000 (errno: Success)
memalign (32768, 32760) = 0x8058000 (errno: Success)
memalign (65536, 65528) = 0x40140000 (errno: Success)

After changing your test code to use posix_memalign, however, I get:

posix_memalign (mem,   128,   120) = (nil) (errno: Invalid argument)
posix_memalign (mem,   256,   248) = (nil) (errno: Invalid argument)
posix_memalign (mem,   512,   504) = (nil) (errno: Invalid argument)
posix_memalign (mem,  1024,  1016) = (nil) (errno: Invalid argument)
posix_memalign (mem,  2048,  2040) = (nil) (errno: Invalid argument)
posix_memalign (mem,  4096,  4088) = (nil) (errno: Invalid argument)
posix_memalign (mem,  8192,  8184) = (nil) (errno: Invalid argument)
posix_memalign (mem, 16384, 16376) = (nil) (errno: Invalid argument)
posix_memalign (mem, 32768, 32760) = (nil) (errno: Invalid argument)
posix_memalign (mem, 65536, 65528) = (nil) (errno: Invalid argument)

Some more fiddling revealed that posix_memalign does work if and only
if I make sure all sizes are multiples of 8:

posix_memalign (mem,   128,   128) = 0x8049880 (errno: Success)
posix_memalign (mem,   256,   256) = 0x8049a00 (errno: Success)
posix_memalign (mem,   512,   512) = 0x8049c00 (errno: Success)
posix_memalign (mem,  1024,  1024) = 0x804a000 (errno: Success)
posix_memalign (mem,  2048,  2048) = 0x804a800 (errno: Success)
posix_memalign (mem,  4096,  4096) = 0x804c000 (errno: Success)
posix_memalign (mem,  8192,  8192) = 0x804e000 (errno: Success)
posix_memalign (mem, 16384, 16384) = 0x8054000 (errno: Success)
posix_memalign (mem, 32768, 32768) = 0x8060000 (errno: Success)
posix_memalign (mem, 65536, 65536) = 0x40140000 (errno: Success)

Not sure if that is postulated by the standard or if it's just a crappy implementation, although a bit of googling seems to indicate it's the implementation. What I haven't checked, yet, is whether they might
have taken the alignment restriction and extended it to the size as
well (so they'd require power of 2 multiples of 8).

fizz@fizz:/ > uname -a
Linux fizz 2.4.31 #1 Wed Jun 1 17:39:13 CEST 2005 i686 unknown
fizz@fizz:/ > ls -al /lib/libc.*
-rwxr-xr-x    1 root     root      1343073 May 11  2001 /lib/libc.so.6
fizz@fizz:/ > rpm -q glibc
glibc-2.2.2-39
Comment 3 Tim Janik 2006-01-24 17:04:22 UTC
thanks jens.
what strikes me as odd here is that you're really encountering this behaviour on a recent glibc...
but anyway, i've committed a tentative check/fix to CVS HEAD now, it'd be good if you could try it out and report on whether it works for you:

Tue Jan 24 17:49:36 2006  Tim Janik  <timj@imendio.com>

        * glib/gslice.c: only use posix_memalign() if it's known to work,
        revert to memalign() otherwise.

        * configure.in: check for broken posix_memalign() implementations
        to fix #328254.

Comment 4 Jens Granseuer 2006-01-25 18:07:50 UTC
Created attachment 58114 [details] [review]
Alternate patch

Version 2.2.2 isn't that new, really.

Your patches work for me, but I'd say they add some unneccessary complexity
(apart from containing a typo ("COMLIANT")).

Why not define HAVE_POSIX_MEMALIGN only if the function is available
and complies with the standard (add the checks to the action-if-found
branch of AC_CHECK_FUNC(posix_memalign)? That way you can drop all the
changes to gslice.c and avoid all the additional complexity.

Plus, you should probably free() what you allocated in test_memalign.

Alternate proposed patch attached.
Comment 5 Tim Janik 2006-01-25 18:23:56 UTC
HAVE_<foo> is somewhat of a standard for AC_CHECK_FUNCS(<foo>), and definig it is actually valid on your system, where posix_memalign() is available and works for 2^n sizes.
i'd not rule out, that we'd want to use that kind of posix_memalign() functionality in the future, so went for the finer destinction of have-posix_memalign and have-compliant-posix_memalign.
my code isn't considerably more complex, i'd say. 
thanks for testing this out on your system, and for reporting the other two buglets, the fixes are in CVS now.