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 772511 - g_log_default_handler crashes windows apps with "Unspecified fatal error encountered, aborting."
g_log_default_handler crashes windows apps with "Unspecified fatal error enco...
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.50.x
Other Windows
: High critical
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2016-10-06 13:01 UTC by Marc-Andre Lureau
Modified: 2016-10-10 13:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
glog: fix crash on windows with --subsystem,windows app (2.72 KB, patch)
2016-10-06 13:19 UTC, Marc-Andre Lureau
committed Details | Review

Description Marc-Andre Lureau 2016-10-06 13:01:20 UTC
A windows application compiled with -Wl,--subsystem,windows has no console attached. When started from the start menu for ex, it will crash when a function attempt to use g_log.


Thread 1 (Thread 2668.0xac)

  • #0 WaitMessage
    from C:\Windows\syswow64\user32.dll
  • #1 WaitMessage
    from C:\Windows\syswow64\user32.dll
  • #2 USER32!DialogBoxIndirectParamW
    from C:\Windows\syswow64\user32.dll
  • #3 USER32!DialogBoxIndirectParamAorW
    from C:\Windows\syswow64\user32.dll
  • #4 USER32!SoftModalMessageBox
    from C:\Windows\syswow64\user32.dll
  • #5 USER32!SoftModalMessageBox
    from C:\Windows\syswow64\user32.dll
  • #6 USER32!MessageBoxTimeoutW
    from C:\Windows\syswow64\user32.dll
  • #7 USER32!MessageBoxTimeoutA
    from C:\Windows\syswow64\user32.dll
  • #8 USER32!MessageBoxExA
    from C:\Windows\syswow64\user32.dll
  • #9 USER32!MessageBoxA
    from C:\Windows\syswow64\user32.dll
  • #10 g_logv
  • #11 g_log
    at gmessages.c line 1337
  • #12 g_return_if_fail_warning
    at gmessages.c line 2453
  • #13 g_log_writer_supports_color
    at gmessages.c line 1826
  • #14 g_log_writer_standard_streams
    at gmessages.c line 2254
  • #15 g_log_writer_default
    at gmessages.c line 2357
  • #16 g_log_structured_array
    at gmessages.c line 1770
  • #17 g_log_default_handler

Comment 1 Marc-Andre Lureau 2016-10-06 13:11:07 UTC
According to https://msdn.microsoft.com/en-us/library/zs6wbdhx.aspx

If stdout or stderr is not associated with an output stream (for example, in a Windows application without a console window), the file descriptor returned is -2. In previous versions, the file descriptor returned was -1. This change allows applications to distinguish this condition from an error.
Comment 2 Marc-Andre Lureau 2016-10-06 13:19:15 UTC
Created attachment 337066 [details] [review]
glog: fix crash on windows with --subsystem,windows app

A windows application compiled with -Wl,--subsystem,windows has no
console attached. When started from the start menu for ex, it will crash
when a function attempt to use g_log:

 #10 0x00a21b26 in g_logv (log_domain=0xa842e1 <__func__.7668+329> "GLib", log_level=G_LOG_LEVEL_CRITICAL, format=0xa845c6 <__func__.7668+1070> "%s: assertion '%s' failed", args=0x28f2bc "PG"")
 #11 0x00a21bb1 in g_log (log_domain=0xa842e1 <__func__.7668+329> "GLib", log_level=G_LOG_LEVEL_CRITICAL, format=0xa845c6 <__func__.7668+1070> "%s: assertion '%s' failed") at gmessages.c:1337
 #12 0x00a22bac in g_return_if_fail_warning (log_domain=0xa842e1 <__func__.7668+329> "GLib", pretty_function=0xa84750 <__func__.65002> "g_log_writer_supports_color",
     expression=0xa844de <__func__.7668+838> "output_fd >= 0") at gmessages.c:2453
 #13 0x00a2239e in g_log_writer_supports_color (output_fd=-2) at gmessages.c:1826
 #14 0x00a226ac in g_log_writer_standard_streams (log_level=G_LOG_LEVEL_WARNING, fields=0x28f3c8, n_fields=4, user_data=0x0) at gmessages.c:2254
 #15 0x00a2290e in g_log_writer_default (log_level=G_LOG_LEVEL_WARNING, fields=0x28f3c8, n_fields=4, user_data=0x0) at gmessages.c:2357

According to https://msdn.microsoft.com/en-us/library/zs6wbdhx.aspx:

If stdout or stderr is not associated with an output stream (for
example, in a Windows application without a console window), the file
descriptor returned is -2. In previous versions, the file descriptor
returned was -1. This change allows applications to distinguish this
condition from an error.

Check if the stream exists and has an associated descriptor and return
G_LOG_WRITER_UNHANDLED if it's not the case.

Fixes:
https://bugzilla.gnome.org/show_bug.cgi?id=772511

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Comment 3 Marc-Andre Lureau 2016-10-10 12:51:03 UTC
raising severity, this bug affects all non-console apps.
Comment 4 Matthias Clasen 2016-10-10 13:39:29 UTC
Attachment 337066 [details] pushed as 615b847 - glog: fix crash on windows with --subsystem,windows app