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 702147 - inconsistency of G_STRFUNC
inconsistency of G_STRFUNC
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.36.x
Other Mac OS
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-06-13 04:56 UTC by Daniel Macks
Modified: 2014-06-10 08:56 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Make G_STRFUNC consistent across platforms (1.45 KB, patch)
2013-06-14 14:25 UTC, Dan Winship
committed Details | Review

Description Daniel Macks 2013-06-13 04:56:55 UTC
built glib-2.36.2 on OS X 10.8, patched configure to remove the -Werror for format-string issues (workaround for Bug #691608, which affects gmarkup.c).


TEST: markup-collect... (pid=71206)
  /markup/collect/0:                                                   OK
  /markup/collect/1:                                                   OK
  /markup/collect/2:                                                   OK
  /markup/collect/3:                                                   OK
  /markup/collect/4:                                                   OK
  /markup/collect/5:                                                   OK
  /markup/collect/6:                                                   OK
  /markup/collect/7:                                                   OK
  /markup/collect/8:                                                   OK
  /markup/collect/9:                                                   OK
  /markup/collect/10:                                                  OK
  /markup/collect/11:                                                  OK
  /markup/collect/12:                                                  OK
  /markup/collect/13:                                                  OK
  /markup/collect/14:                                                  OK
  /markup/collect/15:                                                  OK
  /markup/collect/16:                                                  OK
  /markup/collect/17:                                                  OK
  /markup/collect/cleanup:                                             

(/sw/build.build/glib2-shlibs-2.36.2-1/glib-2.36.2/glib/tests/.libs/markup-collect:71206): GLib-CRITICAL **: Did not see expected message CRITICAL **: g_markup_parse_context_end_parse: assertion `context->state != STATE_ERROR' failed

(/sw/build.build/glib2-shlibs-2.36.2-1/glib-2.36.2/glib/tests/.libs/markup-collect:71206): GLib-CRITICAL **: gboolean g_markup_parse_context_end_parse(GMarkupParseContext *, GError **): assertion `context->state != STATE_ERROR' failed
FAIL



Another tester got same fail for glib-2.34.2 on OS X 10.7
Comment 1 Dan Winship 2013-06-13 14:09:05 UTC
ugh. G_STRFUNC is outputting different text ("gboolean g_markup_parse_context_end_parse(GMarkupParseContext
*, GError **)" rather than just "g_markup_parse_context_end_parse", so the g_test_expect_message() is failing.

Need to figure out if there's someway we can make this be consistent across platforms/compilers or if we need to just make the expectations less strict.
Comment 2 Dan Winship 2013-06-13 20:44:53 UTC
what compiler are you using exactly? And what does this output:

  #include <stdio.h>

  int
  main (int argc, char **argv)
  {
    printf ("__FUNCTION__ is %s\n", __FUNCTION__);
    printf ("__PRETTY_FUNCTION__ is %s\n", __PRETTY_FUNCTION__);
    printf ("__func__ is %s\n", __func__);
    return 0;
  }


More generically, what do people think about this issue? It could be worked around in the test expectations easily enough:

   g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
-                         "g_markup_parse_context_end_parse: assertion 'context->state != STATE_ERROR' failed");
+                         "*g_markup_parse_context_end_parse*assertion 'context->state != STATE_ERROR' failed");

and we can document in g_test_expect_message() that you should do that
Comment 3 Daniel Macks 2013-06-14 09:15:43 UTC
OS X 10.8 with Apple's XCode-4.6.2, and your program foo.c...


$ clang -v
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin12.4.0
Thread model: posix

$ clang foo.c -o foo

$ ./foo
__FUNCTION__ is main
__PRETTY_FUNCTION__ is int main(int, char **)
__func__ is main


$ llvm-gcc -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/src/configure --disable-checking --enable-werror --prefix=/Applications/Xcode.app/Contents/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.11~182/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

$ llvm-gcc foo.c -o foo

$ ./foo
__FUNCTION__ is main
__PRETTY_FUNCTION__ is main
__func__ is main
Comment 4 Dan Winship 2013-06-14 14:25:03 UTC
Created attachment 246814 [details] [review]
Make G_STRFUNC consistent across platforms

Recent versions of clang have changed __PRETTY_FUNCTION__ to always
include the function signature (rather than including the function
signature in C++ but not in C like gcc does). This causes G_STRFUNC to
give different results under clang and gcc, causing some tests with
g_test_expect_messages() to fail.

Fix this by only using __PRETTY_FUNCTION__ in C++, and using
__FUNCTION__ in C. (Under gcc this change has no effect.)
Comment 5 Matthias Clasen 2013-06-16 19:45:04 UTC
Review of attachment 246814 [details] [review]:

ok
Comment 6 Daniel Macks 2013-06-17 09:44:55 UTC
Still fails same way.
Comment 7 Matthias Clasen 2013-06-30 03:26:35 UTC
Attachment 246814 [details] pushed as b7b3838 - Make G_STRFUNC consistent across platforms
Comment 8 Daniel Macks 2014-06-09 03:12:57 UTC
So the patch I said did *not* fix it was pushed and then this bug closed as FIXED??

Anyway, it's still exactly as broken in 2.38.2. From glib/tests/markup-collect.log:

(/sw/build.build/glib2-shlibs-2.38.2-1/glib-2.38.2/glib/tests/.libs/markup-collect:34156): GLib-CRITICAL **: Did not see expected message CRITICAL **: g_markup_parse_context_end_parse: assertion 'context->state != STATE_ERROR' failed
# GLib-FATAL-CRITICAL: gboolean g_markup_parse_context_end_parse(GMarkupParseContext *, GError **): assertion 'context->state != STATE_ERROR' failed

(/sw/build.build/glib2-shlibs-2.38.2-1/glib-2.38.2/glib/tests/.libs/markup-collect:34156): GLib-CRITICAL **: gboolean g_markup_parse_context_end_parse(GMarkupParseContext *, GError **): assertion 'context->state != STATE_ERROR' failed
../../tap-test: line 5: 34156 Trace/BPT trap: 5       $1 -k --tap
Comment 9 Dan Winship 2014-06-09 13:02:52 UTC
a patch would help
Comment 10 Daniel Macks 2014-06-09 17:45:45 UTC
Found it. The committed b7b3838 does work for the G_STRFUNC macro it fixed, but the test is failing due to one of the g_return_* macros, which hardcode __PRETTY_PRINT__ rather than using the (now fixed) one internally...
Comment 11 Daniel Macks 2014-06-09 17:56:43 UTC
...and seems fixed in git via 172aaa3a (in particular: Bug  711047, comment 52).