Skip to content

Crash while initialising a console app #23981

@gwilymk

Description

@gwilymk

Description

Spotted while trying to run kicad-cli and found under the debugger that the crash comes from within wxwidgets.

The following code crashes:

#include <wx/wx.h>

class App : public wxAppConsole
{
public:
	bool OnInit() override
	{
		return true;
	}
};

IMPLEMENT_APP_CONSOLE(App);

compiled simply with

g++ `wx-config --cxxflags` main.cpp -o main `wx-config --libs`

with the following error:

(process:37226): GLib-GObject-CRITICAL **: 19:36:01.730: g_object_get: assertion 'G_IS_OBJECT (object)' failed
free(): invalid pointer
fish: Job 1, './main' terminated by signal SIGABRT (Abort)

backtrace:

#0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
#1  0x00007ffff6aac8a3 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
#2  0x00007ffff6a5c668 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#3  0x00007ffff6a444b8 in __GI_abort () at abort.c:79
#4  0x00007ffff6a45390 in __libc_message (fmt=fmt@entry=0x7ffff6bbc55d "%s\n") at ../sysdeps/posix/libc_fatal.c:150
#5  0x00007ffff6ab67b7 in malloc_printerr (str=str@entry=0x7ffff6bba02b "free(): invalid pointer") at malloc.c:5765
#6  0x00007ffff6ab8a74 in _int_free (av=<optimized out>, p=<optimized out>, have_lock=have_lock@entry=0) at malloc.c:4500
#7  0x00007ffff6abb353 in __GI___libc_free (mem=<optimized out>) at malloc.c:3391
#8  0x00007ffff79cabbd in UpdatePreferDark(GVariant*) (value=value@entry=0x7fffe00025d0) at /usr/src/debug/wxwidgets/wxWidgets-3.2.3/src/gtk/settings.cpp:201
#9  0x00007ffff79cad0a in wxSystemSettingsModule::OnInit() (this=<optimized out>) at /usr/src/debug/wxwidgets/wxWidgets-3.2.3/src/gtk/settings.cpp:1235
#10 0x00007ffff711ee62 in wxModule::Init() (this=0x5555555e8bc0) at /usr/src/debug/wxwidgets/wxWidgets-3.2.3/include/wx/module.h:33
#11 wxModule::DoInitializeModule(wxModule*, wxVector<wxModule*>&) (module=0x5555555e8bc0, initializedModules=...) at /usr/src/debug/wxwidgets/wxWidgets-3.2.3/src/common/module.cpp:137
#12 0x00007ffff7122418 in wxModule::InitializeModules() () at /usr/src/debug/wxwidgets/wxWidgets-3.2.3/src/common/module.cpp:168
#13 0x00007ffff71157a0 in DoCommonPostInit() () at /usr/src/debug/wxwidgets/wxWidgets-3.2.3/src/common/init.cpp:270
#14 0x00007ffff7115faa in wxEntryStart(int&, wchar_t**) (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/wxwidgets/wxWidgets-3.2.3/src/common/init.cpp:336
#15 0x00007ffff7116236 in wxInitialize(int&, wchar_t**) (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/wxwidgets/wxWidgets-3.2.3/src/common/init.cpp:532
#16 0x00007ffff7116360 in wxInitializer::wxInitializer(int&, wchar_t**) (argv=<optimized out>, argc=<optimized out>, this=<synthetic pointer>)
    at /usr/src/debug/wxwidgets/wxWidgets-3.2.3/include/wx/init.h:92
#17 wxEntry(int&, wchar_t**) (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/wxwidgets/wxWidgets-3.2.3/src/common/init.cpp:467
#18 0x000055555555d2cb in main ()

It seems, running it step-by-step under the debugger, that it crashes while freeing the theme name:

g_free(themeName);

Platform and version information

  • wxWidgets version you use: 3.2.3
  • wxWidgets port you use: wxGTK
  • OS and its version: Archlinux
  • GTK version: 3.24.38
  • Which GDK backend is used: X11
  • Current theme: Not sure, but it seems to start with a v from the debugger

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions