Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

free(): invalid pointer in FamiTracker #75

Open
OPNA2608 opened this issue Mar 29, 2021 · 8 comments
Open

free(): invalid pointer in FamiTracker #75

OPNA2608 opened this issue Mar 29, 2021 · 8 comments

Comments

@OPNA2608
Copy link

After working around #73 with some dirty patching of the project files I've successfully built & installed the project in build/famitracker. Upon launching, it prints the following and aborts with SIGABRT:

EnableHtmlHelp
SUPPORT_TRANSLATIONS
Figure out 64-bit version of these asserts...
CControlBar::SetBarStyle
free(): invalid pointer
(Click for debugger backtrace)
Thread 1 ".famitracker-wr" received signal SIGABRT, Aborted.
0x00007ffff63fb33a in raise () from /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libc.so.6
(gdb) bt
#0  0x00007ffff63fb33a in raise () from /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libc.so.6
#1  0x00007ffff63e5523 in abort () from /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libc.so.6
#2  0x00007ffff643b958 in __libc_message () from /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libc.so.6
#3  0x00007ffff644312a in malloc_printerr () from /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libc.so.6
#4  0x00007ffff6444c8c in _int_free () from /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libc.so.6
#5  0x00007ffff7cec432 in ?? () from /nix/store/lxld9304wq6mz08i4m3ma2i4j1irv6xy-famitracker-unstable-2021-03-14/lib/libfamitracker.so.1
#6  0x00000000008d7900 in ?? ()
#7  0x00007ffff7d717a2 in CDC::attach(QWidget*, CWnd*, bool) () from /nix/store/lxld9304wq6mz08i4m3ma2i4j1irv6xy-famitracker-unstable-2021-03-14/lib/libfamitracker.so.1
#8  0x00000000007518f0 in ?? ()
#9  0x00000000007518f0 in ?? ()
#10 0x000000000077f890 in ?? ()
#11 0x00007fffffffceb0 in ?? ()
#12 0x00007ffff7d23df1 in CMainFrame::OnCreate(tagCREATESTRUCTA*) () from /nix/store/lxld9304wq6mz08i4m3ma2i4j1irv6xy-famitracker-unstable-2021-03-14/lib/libfamitracker.so.1
#13 0x00007ffff7d72482 in CWnd::CreateEx(unsigned int, char const*, char const*, unsigned int, tagRECT const&, CWnd*, unsigned int, void*) ()
   from /nix/store/lxld9304wq6mz08i4m3ma2i4j1irv6xy-famitracker-unstable-2021-03-14/lib/libfamitracker.so.1
#14 0x00007ffff7d69cb9 in CFrameWnd::Create(char const*, char const*, unsigned int, tagRECT const&, CWnd*, char const*, unsigned int, CCreateContext*) ()
   from /nix/store/lxld9304wq6mz08i4m3ma2i4j1irv6xy-famitracker-unstable-2021-03-14/lib/libfamitracker.so.1
#15 0x00007ffff7d20c4f in CMainFrame::Create(char const*, char const*, unsigned int, tagRECT const&, CWnd*, char const*, unsigned int, CCreateContext*) ()
   from /nix/store/lxld9304wq6mz08i4m3ma2i4j1irv6xy-famitracker-unstable-2021-03-14/lib/libfamitracker.so.1
#16 0x00007ffff7d6a7fd in CFrameWnd::LoadFrame(unsigned int, unsigned int, CWnd*, CCreateContext*) () from /nix/store/lxld9304wq6mz08i4m3ma2i4j1irv6xy-famitracker-unstable-2021-03-14/lib/libfamitracker.so.1
#17 0x00007ffff7d6a902 in CDocTemplate::CreateNewFrame(CDocument*, CFrameWnd*) () from /nix/store/lxld9304wq6mz08i4m3ma2i4j1irv6xy-famitracker-unstable-2021-03-14/lib/libfamitracker.so.1
#18 0x00007ffff7d6ac4e in CSingleDocTemplate::OpenDocumentFile(char const*, int, int) () from /nix/store/lxld9304wq6mz08i4m3ma2i4j1irv6xy-famitracker-unstable-2021-03-14/lib/libfamitracker.so.1
#19 0x00007ffff7d5bf62 in CWinApp::OpenDocumentFile(char const*) () from /nix/store/lxld9304wq6mz08i4m3ma2i4j1irv6xy-famitracker-unstable-2021-03-14/lib/libfamitracker.so.1
#20 0x00007ffff7d5b2e3 in CWinApp::ProcessShellCommand(CCommandLineInfo&) () from /nix/store/lxld9304wq6mz08i4m3ma2i4j1irv6xy-famitracker-unstable-2021-03-14/lib/libfamitracker.so.1
#21 0x00007ffff7dbdaaf in CFamiTrackerApp::InitInstance() () from /nix/store/lxld9304wq6mz08i4m3ma2i4j1irv6xy-famitracker-unstable-2021-03-14/lib/libfamitracker.so.1
#22 0x000000000040607c in ?? ()
#23 0x00007ffff765c0fe in QWidget::event(QEvent*) () from /nix/store/f0v7b41vx6l7qv9s6f3jrqin7xjifw20-qtbase-5.12.10/lib/libQt5Widgets.so.5
#24 0x00007ffff761ad92 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /nix/store/f0v7b41vx6l7qv9s6f3jrqin7xjifw20-qtbase-5.12.10/lib/libQt5Widgets.so.5
#25 0x00007ffff6c01292 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /nix/store/f0v7b41vx6l7qv9s6f3jrqin7xjifw20-qtbase-5.12.10/lib/libQt5Core.so.5
#26 0x00007ffff7658aa3 in QWidgetPrivate::show_helper() () from /nix/store/f0v7b41vx6l7qv9s6f3jrqin7xjifw20-qtbase-5.12.10/lib/libQt5Widgets.so.5
#27 0x00007ffff765bc63 in QWidgetPrivate::setVisible(bool) () from /nix/store/f0v7b41vx6l7qv9s6f3jrqin7xjifw20-qtbase-5.12.10/lib/libQt5Widgets.so.5
#28 0x000000000040584e in ?? ()
#29 0x00007ffff63e6ded in __libc_start_main () from /nix/store/hp8wcylqr14hrrpqap4wdrwzq092wfln-glibc-2.32-37/lib/libc.so.6

I'm still messing around with this repository. As a test I ran only the following for now:

# downloading & unpacking deps in repo root
cd build/famitracker
qmake && make -j3 && make install
result/
├── bin
│   ├── famitracker
│   └── .famitracker-wrapped
└── lib
    ├── libfamitracker.so -> libfamitracker.so.1.0.0
    ├── libfamitracker.so.1 -> libfamitracker.so.1.0.0
    ├── libfamitracker.so.1.0 -> libfamitracker.so.1.0.0
    ├── libfamitracker.so.1.0.0
    ├── librtmidi.so -> librtmidi.so.1.0.0
    ├── librtmidi.so.1 -> librtmidi.so.1.0.0
    ├── librtmidi.so.1.0 -> librtmidi.so.1.0.0
    └── librtmidi.so.1.0.0

Please let me know if this is not a supported way of installing/running the application, e.g. if building & installing all subprojects is required for the binary to function.

@christopherpow
Copy link
Owner

I don't see anything wrong with what you're doing. When you say "all subprojects" what do you mean exactly? The only subprojects FamiTracker or FamiPlayer need are libfamitracker.so and librtmidi.so.

@OPNA2608
Copy link
Author

Sorry for the vagueness. With this build script in mind, I considered NESICIDE, NES Emulator, FamiTracker and FamiPlayer as this repo's subprojects.

echo Building NESICIDE...
( cd build/ide; qmake; make )
echo Building FamiTracker...
( cd build/nes-emulator; qmake; make )
echo Building FamiPlayer...
( cd build/famiplayer; qmake; make )
echo Building NES Emulator...
( cd build/famitracker; qmake; make )

I only did the cd build/famitracker; qmake; make one (+ make install) instead of building all of those, that's what I meant.

@OPNA2608
Copy link
Author

OPNA2608 commented Apr 1, 2021

Tried building FamiPlayer with CONFIG+=debug instead, that one also crashes with a SIGABRT for me.

EnableHtmlHelp
SUPPORT_TRANSLATIONS
Figure out 64-bit version of these asserts...
QObject::connect: No such slot MainWindow::documentSaved()
QObject::connect:  (receiver name: 'MainWindow')
CControlBar::SetBarStyle
double free or corruption (out)
(debugger backtrace)
Thread 1 ".famiplayer-wra" received signal SIGABRT, Aborted.
0x00007ffff63f733a in raise () from /nix/store/90illc73xfs933d06daq6d41njs8yh66-glibc-2.32-37/lib/libc.so.6
(gdb) bt
#0  0x00007ffff63f733a in raise () from /nix/store/90illc73xfs933d06daq6d41njs8yh66-glibc-2.32-37/lib/libc.so.6
#1  0x00007ffff63e1523 in abort () from /nix/store/90illc73xfs933d06daq6d41njs8yh66-glibc-2.32-37/lib/libc.so.6
#2  0x00007ffff6437958 in __libc_message () from /nix/store/90illc73xfs933d06daq6d41njs8yh66-glibc-2.32-37/lib/libc.so.6
#3  0x00007ffff643f12a in malloc_printerr () from /nix/store/90illc73xfs933d06daq6d41njs8yh66-glibc-2.32-37/lib/libc.so.6
#4  0x00007ffff6441170 in _int_free () from /nix/store/90illc73xfs933d06daq6d41njs8yh66-glibc-2.32-37/lib/libc.so.6
#5  0x00007ffff7cec432 in CBitmap::CreateCompatibleBitmap (this=0x8accf0, pDC=<optimized out>, nWidth=<optimized out>, nHeight=8221712) at ../../common/cqtmfc.h:3301
#6  0x0000000000726f10 in ?? ()
#7  0x00007ffff7d717a2 in CDC::attach (this=0x8accf0, qtParent=<optimized out>, mfcParent=0x71ce00, transparent=<optimized out>) at ../../common/cqtmfc.cpp:3214
#8  0x00000000008accf0 in ?? ()
#9  0x00000000008accf0 in ?? ()
#10 0x00000000006c9bf0 in ?? ()
#11 0x00007fffffffd140 in ?? ()
#12 0x00007ffff7d23df1 in CMainFrame::OnCreate(tagCREATESTRUCTA*) () at Source/MainFrm.cpp:328
#13 0x00007ffff7d72482 in CWnd::CreateEx(unsigned int, char const*, char const*, unsigned int, tagRECT const&, CWnd*, unsigned int, void*) () at ../../common/cqtmfc.cpp:7992
#14 0x00007ffff7d69cb9 in CFrameWnd::Create(char const*, char const*, unsigned int, tagRECT const&, CWnd*, char const*, unsigned int, CCreateContext*) () at ../../common/cqtmfc.cpp:8808
#15 0x00007ffff7d20c4f in CMainFrame::Create (this=this@entry=0x8accf0, lpszClassName=lpszClassName@entry=0x0, lpszWindowName=<optimized out>, dwStyle=dwStyle@entry=13565953, rect=..., 
    pParentWnd=pParentWnd@entry=0x0, lpszMenuName=0x7c2518 "128", dwExStyle=0, pContext=0x7fffffffd3b0) at Source/MainFrm.cpp:310
#16 0x00007ffff7d6a7fd in CFrameWnd::LoadFrame(unsigned int, unsigned int, CWnd*, CCreateContext*) () at ../../common/cqtmfc.cpp:8859
#17 0x00007ffff7d6a902 in CDocTemplate::CreateNewFrame (this=this@entry=0x756670, pDoc=pDoc@entry=0x8d2840, pOther=pOther@entry=0x0) at ../../common/cqtmfc.cpp:11146
#18 0x00007ffff7d6ac4e in CSingleDocTemplate::OpenDocumentFile (this=0x756670, lpszPathName=0x0, bAddToMRU=1, bMakeVisible=1) at ../../common/cqtmfc.cpp:11279
#19 0x00007ffff7d5bf62 in CSingleDocTemplate::OpenDocumentFile (bMakeVisible=1, lpszPathName=0x0, this=<optimized out>) at ../../common/cqtmfc.cpp:11226
#20 CWinApp::OpenDocumentFile (this=0x7ffff7fc9e20 <theApp>, lpszFileName=0x0) at ../../common/cqtmfc.cpp:11776
#21 0x00007ffff7d5b2e3 in CWinApp::ProcessShellCommand (this=this@entry=0x7ffff7fc9e20 <theApp>, rCmdInfo=...) at ../../common/cqtmfc.cpp:11553
#22 0x00007ffff7dbdaaf in CFamiTrackerApp::InitInstance() () at Source/FamiTracker.cpp:238
#23 0x0000000000413b51 in MainWindow::MainWindow(QWidget*) () at mainwindow.cpp:170
#24 0x000000000040e8cc in main () at main.cpp:9
#25 0x00007ffff63e2ded in __libc_start_main () from /nix/store/90illc73xfs933d06daq6d41njs8yh66-glibc-2.32-37/lib/libc.so.6
#26 0x000000000040e9aa in _start () at ../sysdeps/x86_64/start.S:120

Abit of free-form bisecting, not accounting for any changes in your deps download (just picking random commits & testing them):

  • 71bda1f ("Fixes for toolbar impl. Updates to RC generator output."):
    free(): invalid pointer like above
  • 68ea017 ("Removing python IDE files.", commit before 71bda1f):
    EnableHtmlHelp
    SUPPORT_TRANSLATIONS
    Figure out 64-bit version of these asserts...
    Segmentation fault (core dumped)
    
(debugger output for completeness' sake)
Thread 1 ".famitracker-wr" received signal SIGSEGV, Segmentation fault.
0x00007ffff7d70214 in CMenu::AppendMenuA(unsigned int, unsigned long, char const*) () at ../../common/cqtmfc.cpp:11864
11864	{
(gdb) bt
#0  0x00007ffff7d70214 in CMenu::AppendMenuA(unsigned int, unsigned long, char const*) () at ../../common/cqtmfc.cpp:11864
#1  0x00007ffff7d04a75 in qtMfcInitMenuResource_IDR_MAINFRAME(CMenu*) () at /nix/store/8l1rciizh6bdqilkfrgqb3sw1m84xh25-qtbase-5.12.10-dev/include/QtCore/qlist.h:115
#2  0x00007ffff7d06be3 in qtMfcInitMenuResource(unsigned int, CMenu*) () at cqtmfc_famitracker.cpp:1085
#3  0x00007ffff7d5e1c1 in CMenu::LoadMenuA (this=<optimized out>, nIDResource=nIDResource@entry=128) at ../../common/cqtmfc.cpp:11815
#4  0x00007ffff7d6b266 in CFrameWnd::Create(char const*, char const*, unsigned int, tagRECT const&, CWnd*, char const*, unsigned int, CCreateContext*) () at ../../common/cqtmfc.cpp:8714
#5  0x00007ffff7d2289f in CMainFrame::Create (this=this@entry=0x6c1070, lpszClassName=lpszClassName@entry=0x0, lpszWindowName=<optimized out>, dwStyle=dwStyle@entry=13565953, rect=..., 
    pParentWnd=pParentWnd@entry=0x0, lpszMenuName=0x6ed4a8 "128", dwExStyle=0, pContext=0x7fffffffd240) at Source/MainFrm.cpp:310
#6  0x00007ffff7d6be6d in CFrameWnd::LoadFrame(unsigned int, unsigned int, CWnd*, CCreateContext*) () at ../../common/cqtmfc.cpp:8780
#7  0x00007ffff7d6bf72 in CDocTemplate::CreateNewFrame (this=this@entry=0x697fd0, pDoc=pDoc@entry=0x6b6490, pOther=pOther@entry=0x0) at ../../common/cqtmfc.cpp:11004
#8  0x00007ffff7d6c2be in CSingleDocTemplate::OpenDocumentFile (this=0x697fd0, lpszPathName=0x0, bAddToMRU=1, bMakeVisible=1) at ../../common/cqtmfc.cpp:11137
#9  0x00007ffff7d5dfc2 in CSingleDocTemplate::OpenDocumentFile (bMakeVisible=1, lpszPathName=0x0, this=<optimized out>) at ../../common/cqtmfc.cpp:11084
#10 CWinApp::OpenDocumentFile (this=0x7ffff7fc9c80 <theApp>, lpszFileName=0x0) at ../../common/cqtmfc.cpp:11634
#11 0x00007ffff7d5d343 in CWinApp::ProcessShellCommand (this=this@entry=0x7ffff7fc9c80 <theApp>, rCmdInfo=...) at ../../common/cqtmfc.cpp:11411
#12 0x00007ffff7dbec5d in CFamiTrackerApp::InitInstance() () at Source/FamiTracker.cpp:238
#13 0x000000000040507c in MainWindow::showEvent(QShowEvent*) () at mainwindow.cpp:87
#14 0x00007ffff765c0fe in QWidget::event(QEvent*) () from /nix/store/wb5l04r6dgnajhw39v84y10ayiq13mqm-qtbase-5.12.10/lib/libQt5Widgets.so.5
#15 0x00007ffff761ad92 in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /nix/store/wb5l04r6dgnajhw39v84y10ayiq13mqm-qtbase-5.12.10/lib/libQt5Widgets.so.5
#16 0x00007ffff6c01292 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /nix/store/wb5l04r6dgnajhw39v84y10ayiq13mqm-qtbase-5.12.10/lib/libQt5Core.so.5
#17 0x00007ffff7658aa3 in QWidgetPrivate::show_helper() () from /nix/store/wb5l04r6dgnajhw39v84y10ayiq13mqm-qtbase-5.12.10/lib/libQt5Widgets.so.5
#18 0x00007ffff765bc63 in QWidgetPrivate::setVisible(bool) () from /nix/store/wb5l04r6dgnajhw39v84y10ayiq13mqm-qtbase-5.12.10/lib/libQt5Widgets.so.5
#19 0x000000000040484e in main () at main.cpp:11
#20 0x00007ffff63e6ded in __libc_start_main () from /nix/store/90illc73xfs933d06daq6d41njs8yh66-glibc-2.32-37/lib/libc.so.6
#21 0x000000000040490a in _start () at ../sysdeps/x86_64/start.S:120

I'll see about trying this on a more common Linux distro like Ubuntu. Assuming this is generally supposed to be working, maybe the code just doesn't like something about my esoteric system.

@christopherpow
Copy link
Owner

christopherpow commented Apr 1, 2021 via email

@OPNA2608
Copy link
Author

OPNA2608 commented Apr 1, 2021

I tested the new commit, same errors and backtraces as before.

@OPNA2608
Copy link
Author

OPNA2608 commented Apr 2, 2021

FWIW compiling & running on Ubuntu 18.04 (over the network) launches just fine.

Bildschirmfoto von 2021-04-02 10-07-17

I put a breakpoint in CMainFrame::CreateToolbars (this=0x786990) at Source/MainFrm.cpp:445 on my local build & the Ubuntu one and stepped through until they deviated/broke. There seems to be a call to CBitmap::Detach that only happens on my local build? I'll test the Ubuntu build locally after the holidays, let me know if there's anything I could do to help you with debugging this situation.

Local build
(gdb) bt
#0  CMainFrame::CreateToolbars (this=0x786990)
    at Source/MainFrm.cpp:445
#1  0x00007ffff7d22df1 in CMainFrame::OnCreate (this=0x786990, lpCreateStruct=0x7fffffff81f0)
    at Source/MainFrm.cpp:328
#2  0x00007ffff7d71482 in CWnd::CreateEx (this=0x786990, dwExStyle=<optimized out>, lpszClassName=<optimized out>, 
    lpszWindowName=<optimized out>, dwStyle=<optimized out>, rect=..., pParentWnd=0x0, nID=0, lpParam=0x7fffffff8460)
    at ../../common/cqtmfc.cpp:7992
#3  0x00007ffff7d68cb9 in CFrameWnd::Create (this=this@entry=0x786990, lpszClassName=lpszClassName@entry=0x0, 
    lpszWindowName=0x7b2168 "", dwStyle=dwStyle@entry=13565953, rect=..., pParentWnd=0x0,
    lpszMenuName=0x7b2198 "128", dwExStyle=0, pContext=0x7fffffff8460)
    at ../../common/cqtmfc.cpp:8808
#4  0x00007ffff7d1fc4f in CMainFrame::Create (this=this@entry=0x786990, lpszClassName=lpszClassName@entry=0x0, 
    lpszWindowName=<optimized out>, dwStyle=dwStyle@entry=13565953, rect=..., pParentWnd=<optimized out>,
    lpszMenuName=0x7b2198 "128", dwExStyle=0, pContext=0x7fffffff8460)
    at Source/MainFrm.cpp:310
#5  0x00007ffff7d697fd in CFrameWnd::LoadFrame (this=0x786990, nIDResource=<optimized out>, dwDefaultStyle=13565953, 
    pParentWnd=<optimized out>, pContext=0x7fffffff8460)
    at ../../common/cqtmfc.cpp:8859
#6  0x00007ffff7d69902 in CDocTemplate::CreateNewFrame (this=this@entry=0x6229b0, pDoc=pDoc@entry=0x77bc00, pOther=pOther@entry=0x0)
    at ../../common/cqtmfc.cpp:11146
#7  0x00007ffff7d69c4e in CSingleDocTemplate::OpenDocumentFile (this=0x6229b0, lpszPathName=0x0, bAddToMRU=1, bMakeVisible=1)
    at ../../common/cqtmfc.cpp:11279
#8  0x00007ffff7d5af62 in CSingleDocTemplate::OpenDocumentFile (bMakeVisible=1, lpszPathName=0x0, this=<optimized out>)
    at ../../common/cqtmfc.cpp:11226
#9  CWinApp::OpenDocumentFile (this=0x7ffff7fc8e20 <theApp>, lpszFileName=0x0)
    at ../../common/cqtmfc.cpp:11776
#10 0x00007ffff7d5a2e3 in CWinApp::ProcessShellCommand (this=this@entry=0x7ffff7fc8e20 <theApp>, rCmdInfo=...)
    at ../../common/cqtmfc.cpp:11553
#11 0x00007ffff7dbcaaf in CFamiTrackerApp::InitInstance (this=0x7ffff7fc8e20 <theApp>)
    at Source/FamiTracker.cpp:238
#12 0x000000000040507c in MainWindow::showEvent (this=0x7fffffff8a40)
    at mainwindow.cpp:87
#13 0x00007ffff76570fe in QWidget::event(QEvent*) ()
   from /nix/store/qbffg675hqpskzg6lgvzbcmnvlgnxr64-qtbase-5.12.10/lib/libQt5Widgets.so.5
#14 0x00007ffff7615d92 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from /nix/store/qbffg675hqpskzg6lgvzbcmnvlgnxr64-qtbase-5.12.10/lib/libQt5Widgets.so.5
#15 0x00007ffff6bfc292 in QCoreApplication::notifyInternal2(QObject*, QEvent*) ()
   from /nix/store/qbffg675hqpskzg6lgvzbcmnvlgnxr64-qtbase-5.12.10/lib/libQt5Core.so.5
#16 0x00007ffff7653aa3 in QWidgetPrivate::show_helper() ()
   from /nix/store/qbffg675hqpskzg6lgvzbcmnvlgnxr64-qtbase-5.12.10/lib/libQt5Widgets.so.5
#17 0x00007ffff7656c63 in QWidgetPrivate::setVisible(bool) ()
   from /nix/store/qbffg675hqpskzg6lgvzbcmnvlgnxr64-qtbase-5.12.10/lib/libQt5Widgets.so.5
#18 0x000000000040484e in main (argc=<optimized out>, argv=<optimized out>)
    at main.cpp:11
(gdb) step
CBitmap::Attach (this=this@entry=0x787660, hObject=hObject@entry=0x5e4070) at ../../common/cqtmfc.cpp:3037
3037	  CGdiObject::Attach(hObject);
(gdb) 
CGdiObject::Attach (hObject=hObject@entry=0x5e4070, this=this@entry=0x787660) at ../../common/cqtmfc.h:3300
3300	  BOOL Attach(HGDIOBJ hObject) { m_hObject = hObject; }
(gdb) 
CBitmap::Detach (this=0x787660) at ../../common/cqtmfc.cpp:3045
3045	  this->_qpixmap = 0;
(gdb) 
3046	  _owned = false;
(gdb) 
3047	  return CGdiObject::Detach();
(gdb) 
CGdiObject::Detach (this=0x787660) at ../../common/cqtmfc.h:3301
3301	  HGDIOBJ Detach() { m_hObject = 0; }
(gdb) 
0x00007ffff6786420 in operator delete(void*) () from /nix/store/fmxgxr7kx29aqbzjp662v5mhkrbjvl91-gcc-10.2.0-lib/lib/libstdc++.so.6
(gdb) 
Single stepping until exit from function _ZdlPv,
which has no line number information.
0x00007ffff6443020 in free () from /nix/store/90illc73xfs933d06daq6d41njs8yh66-glibc-2.32-37/lib/libc.so.6
(gdb) 
Single stepping until exit from function free,
which has no line number information.
0x00007ffff643f9c0 in _int_free () from /nix/store/90illc73xfs933d06daq6d41njs8yh66-glibc-2.32-37/lib/libc.so.6
(gdb) 
Single stepping until exit from function _int_free,
which has no line number information.
free(): invalid pointer

Thread 1 ".famitracker-wr" received signal SIGABRT, Aborted.
0x00007ffff63f633a in raise () from /nix/store/90illc73xfs933d06daq6d41njs8yh66-glibc-2.32-37/lib/libc.so.6
Ubuntu build
(gdb) bt
#0  CMainFrame::CreateToolbars (this=0x555555a171e0)
    at Source/MainFrm.cpp:445
#1  0x00007ffff78950d3 in CMainFrame::OnCreate (this=0x555555a171e0, lpCreateStruct=0x7fffffffd240)
    at Source/MainFrm.cpp:328
#2  0x00007ffff7904787 in CWnd::CreateEx (this=0x555555a171e0, dwExStyle=0, lpszClassName=0x555555a171e0 "p&\323\367\377\177", 
    lpszWindowName=0x555555a3a628 "", dwStyle=13565953, rect=..., pParentWnd=0x0, nID=0, lpParam=0x7fffffffd570)
    at ../../common/cqtmfc.cpp:8014
#3  0x00007ffff790422a in CWnd::Create (this=0x555555a171e0, lpszClassName=0x555555a171e0 "p&\323\367\377\177", 
    lpszWindowName=0x555555a3a628 "", dwStyle=13565953, rect=..., pParentWnd=0x0,
    lpszMenuName=0x555555a3a658 "128", dwExStyle=0, pContext=0x7fffffffd570)
    at ../../common/cqtmfc.cpp:7943
#4  0x00007ffff790758e in CFrameWnd::Create (this=0x555555a171e0, lpszClassName=0x555555a171e0 "p&\323\367\377\177", 
    lpszWindowName=0x555555a3a628 "", dwStyle=13565953, rect=..., pParentWnd=0x0,
    lpszMenuName=0x555555a3a658 "128", dwExStyle=0, pContext=0x7fffffffd570)
    at ../../common/cqtmfc.cpp:8808
#5  0x00007ffff7894fec in CMainFrame::Create (this=0x555555a171e0, lpszClassName=0x555555a171e0 "p&\323\367\377\177", 
    lpszWindowName=0x555555a3a628 "", dwStyle=13565953, rect=..., pParentWnd=0x0,
    lpszMenuName=0x555555a3a658 "128", dwExStyle=0, pContext=0x7fffffffd570)
    at Source/MainFrm.cpp:310
#6  0x00007ffff790792d in CFrameWnd::LoadFrame (this=0x555555a171e0, nIDResource=128, dwDefaultStyle=13565953,
    pParentWnd=0x0, pContext=0x7fffffffd570)
    at ../../common/cqtmfc.cpp:8859
#7  0x00007ffff7910d28 in CDocTemplate::CreateNewFrame (this=0x55555593f500, pDoc=0x555555a0c540, pOther=0x0)
    at ../../common/cqtmfc.cpp:11146
#8  0x00007ffff7911b5a in CSingleDocTemplate::OpenDocumentFile (this=0x55555593f500, lpszPathName=0x0, bAddToMRU=1, bMakeVisible=1)
    at ../../common/cqtmfc.cpp:11279
#9  0x00007ffff7911503 in CSingleDocTemplate::OpenDocumentFile (this=0x55555593f500, lpszPathName=0x0, bMakeVisible=1)
    at ../../common/cqtmfc.cpp:11226
#10 0x00007ffff7913f1a in CWinApp::OpenDocumentFile (this=0x7ffff7dd1a00 <theApp>, lpszFileName=0x0)
    at ../../common/cqtmfc.cpp:11776
#11 0x00007ffff7912ebc in CWinApp::ProcessShellCommand (this=0x7ffff7dd1a00 <theApp>, rCmdInfo=...)
    at ../../common/cqtmfc.cpp:11553
#12 0x00007ffff799e09d in CFamiTrackerApp::InitInstance (this=0x7ffff7dd1a00 <theApp>)
    at Source/FamiTracker.cpp:238
#13 0x000055555555a0eb in MainWindow::showEvent (this=0x7fffffffde10)
    at mainwindow.cpp:87
#14 0x00007ffff7060048 in QWidget::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#15 0x00007ffff7173c6b in QMainWindow::event(QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#16 0x00007ffff702183c in QApplicationPrivate::notify_helper(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#17 0x00007ffff7029104 in QApplication::notify(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#18 0x00007ffff62a38d8 in QCoreApplication::notifyInternal2(QObject*, QEvent*) () from /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
#19 0x00007ffff705cf18 in QWidgetPrivate::show_helper() () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#20 0x00007ffff705fbeb in QWidget::setVisible(bool) () from /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5
#21 0x00005555555597ff in main (argc=1, argv=0x7fffffffdf58)
    at main.cpp:11
(gdb) step
CBitmap::Attach (this=0x555555a17eb0, hObject=0x555555930620) at ../../common/cqtmfc.cpp:3037
3037	  CGdiObject::Attach(hObject);
(gdb) 
CGdiObject::Attach (this=0x555555a17eb0, hObject=0x555555930620) at ../../common/cqtmfc.h:3300
3300	  BOOL Attach(HGDIOBJ hObject) { m_hObject = hObject; }
(gdb) 
CBitmap::Attach (this=0x555555a17eb0, hObject=0x555555930620) at ../../common/cqtmfc.cpp:3038
3038	  CBitmap* pBitmap = (CBitmap*)hObject;
(gdb) 
3039	  this->_qpixmap = pBitmap->toQPixmap();
(gdb) 
CBitmap::toQPixmap (this=0x555555930620) at ../../common/cqtmfc.h:3351
3351	  QPixmap* toQPixmap() { return _qpixmap; }
(gdb) 
CBitmap::Attach (this=0x555555a17eb0, hObject=0x555555930620) at ../../common/cqtmfc.cpp:3040
3040	  this->_owned = false;
(gdb) 
3041	}
(gdb) 
CMainFrame::CreateToolbars (this=0x555555a171e0) at Source/MainFrm.cpp:447
447	  m_ilToolBar.Create(16, 15, ILC_COLOR8 | ILC_MASK, 4, 4);

Edit: The Ubuntu 18.04 machine has Qt 5.9.5, my local machine has 5.12.10. Copying the Ubuntu build's binary & libraries to my local machine and relinking everything against my system libraries makes it launch properly. Stepping through, it doesn't hit the detach code. I guess this is a problem with the build then and nothing that's weird at runtime?

@OPNA2608
Copy link
Author

OPNA2608 commented Apr 2, 2021

I had a hunch and tested various versions of GCC. GCC 6 and GCC 7 produce binaries that launch fine, GCC 8 and higher seem to cause these launch failures. Ubuntu 18.04's default compiler is GCC 7.4 hence the builds worked fine there, my distro's default compiler is GCC 10.

@christopherpow
Copy link
Owner

Thanks for the investigation help! I'll have to take a closer look at the traces you sent. At a glance it seems there's something wrong with the waveform window's Y position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants