GNOME Bugzilla – Bug 106091
strfunc-test failure in glib 2.2.1
Last modified: 2011-02-18 15:58:17 UTC
With GCC 3.2.2, glib-2.2.1, in a stow environment ./configure \ --prefix=${SHOP_STOW}/${SHOP_PACKAGE} \ --exec-prefix=${SHOP_STOW}/${SHOP_PACKAGE}/${SHOP_CONFIG} \ --with-gnu-ld \ --with-libiconv-prefix=${SHOP_STOW}/${LIBICONV}/${SHOP_CONFIG} \ --with-threads=posix \ --with-libiconv=gnu [sparc-sun-solaris2.6, 2.7 and 2.8] failure on strfunc-test $ ./strfunc-test (strfunc-test.c:449) failed for: 3 == g_snprintf (buf, 0, "%s", "abc") (strfunc-test.c:450) failed for: 3 == g_snprintf (NULL,0, "%s", "abc")
*** Bug 109268 has been marked as a duplicate of this bug. ***
*** Bug 108249 has been marked as a duplicate of this bug. ***
*** Bug 110680 has been marked as a duplicate of this bug. ***
Bug 110680 has more information and a possible fix. It's not 100% clear to me that Bug 108249 is actually a duplicate; it looks a bit different.
If you look at the stacktrace in bug 108249, frame 14 shows that it is a case of calling g_vsnprintf with a NULL buffer, which then goes into _trio_vsnprintf and bumps into the same assert that is discussed in bug 110680.
Are we sure there aren't multiple different bugs combined here .... one seems to be an assertion failure in trio, a second (the original bug here and one of the failures in 106951) being a problem where Solaris native printf isn't C99 compliant but we don't catch it?
*** Bug 114825 has been marked as a duplicate of this bug. ***
*** Bug 114963 has been marked as a duplicate of this bug. ***
*** Bug 115035 has been marked as a duplicate of this bug. ***
*** Bug 115758 has been marked as a duplicate of this bug. ***
The possible fix in Bug 110680 does not work for me. That bug says: >trio's *snprintf* functions don't allow buffer to be NULL even when >max is 0, making them non-C99-compliant, and making strfunc-test >fail. > >Changing the assertions from > assert(VALID(buffer)); >to > assert(VALID(buffer) || max == 0); > >makes strfunc-test pass, although I haven't figured out if it could >cause crashes elsewhere However, I have applied that patch but I still see the two failures of strfunc-test. This is because on my system glib is not using the trio code at all! To demonstrate this: % tar x --bzip2 <glib-2.2.2.tar.bz2 % cd glib-2.2.2 % ./configure [...] % rm -rf glib/trio % make -j -l 1 [succeeds] % make -j -l 1 check [...] (strfunc-test.c:449) failed for: 3 == g_snprintf (buf, 0, "%s", "abc") (strfunc-test.c:450) failed for: 3 == g_snprintf (NULL,0, "%s", "abc") FAIL: strfunc-test [...] In other words I am able to successfully build glib after completely removing the glib/trio/ directory, showing that it is not used. But nonetheless I get the two test failures above. My system is SunOS 5.8 Generic_108528-15 sun4u sparc SUNW,Sun-Fire-280R Solaris.
I think the reason I'm getting the same strfunc-test failures, despite not using trio, is that my system's libc has the same bug. I tried patching trio by changing the assertions as suggested, and then configuring with --enable-included-printf. This made strfunc-test pass but broke a different test: ** ERROR **: file strtod-test.c: line 49 (main): assertion failed: (d == g_ascii_strtod (g_ascii_dtostr (buffer, sizeof (buffer), d), NULL)) aborting... FAIL: strtod-test However, this failure of strtod-test seems to always occur when I give --enable-included-printf, whether or not the patch to assert(VALID(buffer)) is applied, so I will report it in a separate bug. In summary, it looks like this is the case: - trio's snprintf() doesn't behave correctly with a zero-sized buffer; - neither does the stock snprintf() on Solaris 2.8; - therefore either of these can produce a failure of strfunc-test. A possible plan to fix this would be: - Add an autoconf test for snprintf() with a zero-size buffer, to catch systems where this doesn't work properly. If the stock snprintf() is broken then configure should avoid using it (HAVE_GOOD_PRINTF should not be set). - Fix glib/trio/ so that snprintf() works correctly with a zero size buffer. I don't know if this bug is already fixed in the upstream trio sources.
I've done those changes now. Would you mind testing them on your system ? Ideally you should test the glib-2-2 branch and HEAD, since HEAD uses a different fallback implementation instead of trio.
### glib-2-2 branch @@ i686-pc-linux-gnu: FAIL: module-test @@ sparc-sun-solaris2.7: FAIL: module-test FAIL: patterntest (strfunc-test.c:449) failed for: 3 == g_snprintf (buf, 0, "%s", "abc") (strfunc-test.c:450) failed for: 3 == g_snprintf (NULL,0, "%s", "abc") FAIL: strfunc-test @@ sparc-sun-solaris2.8: FAIL: iochannel-test FAIL: module-test FAIL: patterntest (strfunc-test.c:449) failed for: 3 == g_snprintf (buf, 0, "%s", "abc") (strfunc-test.c:450) failed for: 3 == g_snprintf (NULL,0, "%s", "abc") FAIL: strfunc-test ### HEAD @@ i686-pc-linux-gnu: FAIL: module-test @@ sparc-sun-solaris2.7: FAIL: file-test FAIL: env-test FAIL: module-test FAIL: unicode-encoding (strfunc-test.c:449) failed for: 3 == g_snprintf (buf, 0, "%s", "abc") (strfunc-test.c:450) failed for: 3 == g_snprintf (NULL,0, "%s", "abc") FAIL: strfunc-test @@ sparc-sun-solaris2.8: FAIL: env-test FAIL: iochannel-test FAIL: module-test (strfunc-test.c:449) failed for: 3 == g_snprintf (buf, 0, "%s", "abc") (strfunc-test.c:450) failed for: 3 == g_snprintf (NULL,0, "%s", "abc") FAIL: strfunc-test
Did you build from a clean checkout ? I've added new macros to configure.in and acinclude.m4, so you'll need at least aclocal autoconf ./configure make to test my changes
I got files from CVS some hours ago, put them in new dirs. Launch ./autogen.sh [*], make, make check. [*] I had problems with AM_PROG_LIBTOOL and AM_DISABLE_STATIC, and I shortcut the gtk-doc part for the CVS HEAD, but I think it's unrelated with this bug. glib-2-2 i686-pc-linux-gnu ac_cv_func_printf_unix98=yes ac_cv_func_vasprintf=yes ac_cv_func_vprintf=yes ac_cv_func_vsnprintf=yes ac_cv_func_vsnprintf_c99=yes HEAD i686-pc-linux-gnu ac_cv_func_printf_unix98=yes ac_cv_func_snprintf=yes ac_cv_func_snprintf_c99=yes ac_cv_func_vasprintf=yes ac_cv_func_vprintf=yes ac_cv_func_vsnprintf=yes ac_cv_func_vsnprintf_c99=yes glib-2-2 sparc-sun-solaris2.7 ac_cv_func_printf_unix98=yes ac_cv_func_vasprintf=no ac_cv_func_vprintf=yes ac_cv_func_vsnprintf=yes ac_cv_func_vsnprintf_c99=yes HEAD sparc-sun-solaris2.7 ac_cv_func_printf_unix98=yes ac_cv_func_snprintf=yes ac_cv_func_snprintf_c99=no ac_cv_func_vasprintf=no ac_cv_func_vprintf=yes ac_cv_func_vsnprintf=yes ac_cv_func_vsnprintf_c99=yes glib-2-2 sparc-sun-solaris2.8 ac_cv_func_printf_unix98=yes ac_cv_func_vasprintf=no ac_cv_func_vprintf=yes ac_cv_func_vsnprintf=yes ac_cv_func_vsnprintf_c99=yes HEAD sparc-sun-solaris2.8 ac_cv_func_printf_unix98=yes ac_cv_func_snprintf=yes ac_cv_func_snprintf_c99=no ac_cv_func_vasprintf=no ac_cv_func_vprintf=yes ac_cv_func_vsnprintf=yes ac_cv_func_vsnprintf_c99=yes
Hmm, is this from anonymous cvs ? Then the the mirrors could lag, because I added a AC_FUNC_SNPRINTF_C99 to glib-2-2 configure.in. What I notice now is that I missed to put the following lines in: if test "$ac_cv_func_snprintf_c99" != "yes" ; then need_trio=yes fi They should go next to the corresponding if for vsnprintf. Do the other failing tests produce any output ?
Yes, anonymous CVS (anoncvs.gnome.org). Outputs for other failed tests: ** (process:18360): WARNING **: Could not open converter from `UTF-8' to `EUC-JP': No such file or directory FAIL: iochannel-test ** ERROR **: error: global state should have been "global clash", but is "NULL" FAIL: module-test (process:29597): GLib-CRITICAL **: file gpattern.c: line 184 (g_pattern_spec_new): assertion `pattern != NULL' failed FAIL: patterntest (strfunc-test.c:449) failed for: 3 == g_snprintf (buf, 0, "%s", "abc") (strfunc-test.c:450) failed for: 3 == g_snprintf (NULL,0, "%s", "abc") FAIL: strfunc-test ** ERROR **: file env-test.c: line 103 (main): assertion failed: (strcmp (data, "baz") == 0 && "g_getenv() doesn't support '=' in names") FAIL: env-test line 40: could not convert to UTF-16 via g_convert line 44: could not convert to UTF-16 via g_convert line 60: could not convert to UTF-16 via g_convert line 82: could not convert to UTF-16 via g_convert line 94: could not convert to UTF-16 via g_convert line 299: could not convert to UTF-16 via g_convert FAIL: unicode-encoding
I have also tried latest CVS as of about 2003-08-15 12:00 UTC: % cvs -q update -Pd % ./autogen.sh --prefix=$HOME --with-included-printf --with-xml-catalog=$HOME/etc/xml/catalog % make % make check yet the last command includes in its output: (strfunc-test.c:449) failed for: 3 == g_snprintf (buf, 0, "%s", "abc") (strfunc-test.c:450) failed for: 3 == g_snprintf (NULL,0, "%s", "abc") FAIL: strfunc-test
Does this still happen with 2.3.x ?
No response, closing.