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 106091 - strfunc-test failure in glib 2.2.1
strfunc-test failure in glib 2.2.1
Status: VERIFIED INCOMPLETE
Product: glib
Classification: Platform
Component: general
2.2.x
Other Solaris
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: 108249 109268 110680 114825 114963 115035 115758 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2003-02-14 15:13 UTC by Benoît Sibaud
Modified: 2011-02-18 15:58 UTC
See Also:
GNOME target: ---
GNOME version: 2.1/2.2



Description Benoît Sibaud 2003-02-14 15:13:34 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")
Comment 1 Matthias Clasen 2003-03-27 00:08:32 UTC
*** Bug 109268 has been marked as a duplicate of this bug. ***
Comment 2 Matthias Clasen 2003-05-05 08:33:03 UTC
*** Bug 108249 has been marked as a duplicate of this bug. ***
Comment 3 Matthias Clasen 2003-05-05 08:39:46 UTC
*** Bug 110680 has been marked as a duplicate of this bug. ***
Comment 4 Owen Taylor 2003-05-22 18:23:24 UTC
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.
Comment 5 Matthias Clasen 2003-05-22 18:27:55 UTC
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.
Comment 6 Owen Taylor 2003-05-22 18:51:38 UTC
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?
Comment 7 Owen Taylor 2003-06-10 18:30:30 UTC
*** Bug 114825 has been marked as a duplicate of this bug. ***
Comment 8 Matthias Clasen 2003-06-12 06:54:17 UTC
*** Bug 114963 has been marked as a duplicate of this bug. ***
Comment 9 Matthias Clasen 2003-06-12 17:18:36 UTC
*** Bug 115035 has been marked as a duplicate of this bug. ***
Comment 10 Matthias Clasen 2003-06-23 07:30:57 UTC
*** Bug 115758 has been marked as a duplicate of this bug. ***
Comment 11 Ed Avis 2003-08-07 08:05:25 UTC
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.
Comment 12 Ed Avis 2003-08-07 15:43:45 UTC
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.
Comment 13 Matthias Clasen 2003-08-07 20:54:42 UTC
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.
Comment 14 Benoît Sibaud 2003-08-08 10:27:14 UTC
### 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
Comment 15 Matthias Clasen 2003-08-08 10:57:42 UTC
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
Comment 16 Benoît Sibaud 2003-08-08 11:54:14 UTC
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
Comment 17 Matthias Clasen 2003-08-08 12:10:28 UTC
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 ?
Comment 18 Benoît Sibaud 2003-08-08 13:42:26 UTC
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

Comment 19 Ed Avis 2003-08-15 15:34:14 UTC
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


Comment 20 Matthias Clasen 2003-11-13 07:57:26 UTC
Does this still happen with 2.3.x ?
Comment 21 Matthias Clasen 2004-10-23 23:20:22 UTC
No response, closing.