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

Crash at startup on MinGW 64 builds #1522

Closed
hmartinez82 opened this issue Mar 9, 2024 · 6 comments · Fixed by mltframework/mlt#974
Closed

Crash at startup on MinGW 64 builds #1522

hmartinez82 opened this issue Mar 9, 2024 · 6 comments · Fixed by mltframework/mlt#974
Milestone

Comments

@hmartinez82
Copy link

OS: MINGW64_NT-10.0-22631 3.4.10.x86_64 2024-02-10 08:39 UTC x86_64 Msys
MLT: 7.22.0
Shotcut: 24.02.29
GCC: 13.2.0

MinGW 64 builds of Shotcut are crashing at startup when using MSYS2's MINGW64 environment.
Surprisingly this is only affecting GCC builds. The Clang builds in both CLANG64 and CLANGARM64 do not show this issue.

Steps to reproduce:

  • Open the UCRT64 or MINGW64 environment in MSYS2
  • Export QSG_RHI_BACKEND=d3d11 (This was done so gdb would attach to the right process)
  • Run shotcut.exe

Expected

  • Shotcut launches correclty

Actual

  • Shotcut crashes after briefly showing the splash screen

GDB's backtrace provided:

Starting program: C:\msys64\mingw64\bin\shotcut.exe
[New Thread 23856.0x65ac]
[New Thread 23856.0x619c]
[New Thread 23856.0x79cc]
[New Thread 23856.0x7c84]
[New Thread 23856.0x3e20]
warning: clientcore\windows\advcore\ctf\uim\tim.cpp(800)\MSCTF.dll!00007FFDB42065D9: (caller: 00007FFDB420720C) LogHr(1) tid(81cc) 8007029C An assertion failure has occurred.
warning: clientcore\windows\advcore\ctf\uim\tim.cpp(800)\MSCTF.dll!00007FFDB42065D9: (caller: 00007FFDB420720C) LogHr(2) tid(81cc) 8007029C An assertion failure has occurred.
[New Thread 23856.0x5d80]
[New Thread 23856.0x6b4c]
[New Thread 23856.0x18e0]
[New Thread 23856.0x4dc8]
[New Thread 23856.0x64c0]
[New Thread 23856.0x2680]
[New Thread 23856.0x3788]
[New Thread 23856.0x3d14]
[New Thread 23856.0x71bc]
[New Thread 23856.0x5380]
[New Thread 23856.0x3a1c]
[New Thread 23856.0x666c]
[New Thread 23856.0x3020]
[New Thread 23856.0x300c]
gdb: unknown target exception 0xc0000409 at 0x7ffd5bf8b48e

Thread 1 received signal ?, Unknown signal.
0x00007ffd5bf8b48e in __fastfail (code=8) at D:/a/msys64/mingw64/include/_mingw.h:605
warning: 605    D:/a/msys64/mingw64/include/_mingw.h: No such file or directory
(gdb) bt
#0  0x00007ffd5bf8b48e in __fastfail (code=8) at D:/a/msys64/mingw64/include/_mingw.h:605
#1  __chk_fail () at C:/M/B/src/mingw-w64/mingw-w64-crt/ssp/chk_fail.c:18
#2  0x00007ffd5bf83143 in list_presets.isra () from C:\msys64\mingw64\bin\libmlt-7.dll
#3  0x00007ffd5bf830bf in list_presets.isra () from C:\msys64\mingw64\bin\libmlt-7.dll
#4  0x00007ffd5bf83239 in list_presets.isra () from C:\msys64\mingw64\bin\libmlt-7.dll
#5  0x00007ffd5bf83f73 in mlt_repository_presets () from C:\msys64\mingw64\bin\libmlt-7.dll
#6  0x00007ffd60ceaff8 in Mlt::Repository::presets() () from C:\msys64\mingw64\bin\libmlt++-7.dll
#7  0x00007ff617332acc in EncodeDock::EncodeDock (this=this@entry=0x61779a0, parent=parent@entry=0x266d070)
    at X:/Github/MINGW-packages/mingw-w64-shotcut/src/shotcut-24.02.29/src/docks/encodedock.cpp:59
#8  0x00007ff6173adfb2 in MainWindow::setupAndConnectDocks (this=this@entry=0x266d070)
    at X:/Github/MINGW-packages/mingw-w64-shotcut/src/shotcut-24.02.29/src/mainwindow.cpp:623
#9  0x00007ff6173b9446 in MainWindow::MainWindow (this=0x266d070)
    at X:/Github/MINGW-packages/mingw-w64-shotcut/src/shotcut-24.02.29/src/mainwindow.cpp:208
#10 0x00007ff6173b9820 in MainWindow::singleton ()
    at X:/Github/MINGW-packages/mingw-w64-shotcut/src/shotcut-24.02.29/src/mainwindow.cpp:798
#11 0x00007ff61739714d in qMain (argc=<optimized out>, argv=<optimized out>)
    at X:/Github/MINGW-packages/mingw-w64-shotcut/src/shotcut-24.02.29/src/main.cpp:422
#12 0x00007ff6174be9c7 in qtEntryPoint() ()
#13 0x00007ff6172d12ee in __tmainCRTStartup () at C:/M/B/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:267
#14 0x00007ff6172d13e6 in WinMainCRTStartup () at C:/M/B/src/mingw-w64/mingw-w64-crt/crt/crtexe.c:157
@bmatherly
Copy link
Member

Our nightly builds are using MSYS2 and MINGW64 (GCC 13.2).

The workflow file is here:
https://github.com/mltframework/shotcut/blob/master/.github/workflows/build-windows.yml
Here is last night's run:
https://github.com/mltframework/shotcut/actions/runs/8213183222

A quick google search for "unknown target exception" suggests this is a common message when the GDB version does not match the GCC version (64/32 bit)

I'm afraid you are unlikely to find much help on this forum since we do not recreate the problem with our build system.

@hmartinez82
Copy link
Author

hmartinez82 commented Mar 10, 2024

@bmatherly Could you try building in Debug mode?
Surprisingly I only see this error when I tried to build mlt in Debug build type:

-- Build files have been written to: D:/Dev/Github/MINGW-packages/mingw-w64-mlt/src/build-MINGW64
[92/311] Building C object src/framework/CMakeFiles/mlt.dir/mlt_repository.c.obj
FAILED: src/framework/CMakeFiles/mlt.dir/mlt_repository.c.obj
C:\msys64\mingw64\bin\gcc.exe -DDLFCN_WIN32_SHARED -DNODEPLOY -Dmlt_EXPORTS -ID:/Dev/Github/MINGW-packages/mingw-w64-mlt/src/mlt-7.18.0/src/framework/.. -march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -ggdb -Og -ffile-prefix-map=/d/Dev/Github/MINGW-packages/mingw-w64-mlt/src=/usr/src/debug/mingw-w64-mlt -Wno-int-conversion -Wall -Werror -Wno-deprecated-declarations -Wno-discarded-qualifiers -g -std=gnu11 -mmmx -msse -msse2 -MD -MT src/framework/CMakeFiles/mlt.dir/mlt_repository.c.obj -MF src\framework\CMakeFiles\mlt.dir\mlt_repository.c.obj.d -o src/framework/CMakeFiles/mlt.dir/mlt_repository.c.obj -c D:/Dev/Github/MINGW-packages/mingw-w64-mlt/src/mlt-7.18.0/src/framework/mlt_repository.c
In file included from C:/msys64/mingw64/include/_mingw.h:10,
                 from C:/msys64/mingw64/include/corecrt.h:10,
                 from C:/msys64/mingw64/include/crtdefs.h:10,
                 from C:/msys64/mingw64/include/inttypes.h:11,
                 from X:/Github/MINGW-packages/mingw-w64-mlt/src/mlt-7.18.0/src/framework/mlt_types.h:34,
                 from X:/Github/MINGW-packages/mingw-w64-mlt/src/mlt-7.18.0/src/framework/mlt_profile.h:26,
                 from X:/Github/MINGW-packages/mingw-w64-mlt/src/mlt-7.18.0/src/framework/mlt_repository.h:26,
                 from X:/Github/MINGW-packages/mingw-w64-mlt/src/mlt-7.18.0/src/framework/mlt_repository.c:23:
In function 'snprintf',
    inlined from 'list_presets' at X:/Github/MINGW-packages/mingw-w64-mlt/src/mlt-7.18.0/src/framework/mlt_repository.c:583:25:
C:/msys64/mingw64/include/stdio.h:458:3: error: call to '__mingw_chk_fail_warn' declared with attribute warning: Buffer overflow detected [-Werror=attribute-warning]
  458 |   __mingw_bos_ptr_chk_warn(__stream, __n, 1);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~
cc1.exe: all warnings being treated as errors
[117/311] Building C object src/modules/avformat/CMakeFiles/mltavformat.dir/producer_avformat.c.obj
ninja: build stopped: subcommand failed.
==> ERROR: A failure occurred in build().
    Aborting...

@bmatherly
Copy link
Member

That is probably happening because we treat warnings as errors when compiling in debug mode:
https://github.com/mltframework/mlt/blob/master/CMakeLists.txt#L148

I eventually get around to fixing these when I am forced to upgrade my system and the new version of GCC triggers new warnings. I'm not available to help reproduce and debug this right now. But maybe you can make a quick patch to satisfy the warning/error. If you do, send it my way and I can merge it in to master.

@hmartinez82
Copy link
Author

I got around by replacing the three usages of snprintf with _snprintf. Now not only the debug build completes. The error is gone, and is fixed in Release too😮

@hmartinez82
Copy link
Author

@bmatherly I think I found out. And still using snprintf instead of _snprintf:
https://github.com/mltframework/mlt/blob/7930382303eb2c1c044bd68e8b40dcf99e5a9b63/src/framework/mlt_repository.c#L584 should use sizeof(fullname) instead of 1024

@ddennedy
Copy link
Member

Weird. Our SDK builds in debug mode and has not experienced the build error
https://github.com/mltframework/shotcut/actions/workflows/build-sdk-windows.yml

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