FreeType CRASH in Preferences Dialog when change a path using Native File Dialog on archlinux (x86+armv7a)
I've tested this on latest master https://github.com/musescore/musescore/commit/e666061 and it happens on both my i686 machine and ARMv7A machine, both running latest archlinux. In the Preferences Dialogue, when I try to change the path for any of the {Scores,Styles,Templates,Plugins,Soundfonts,Images} folders or starting score, then I the windows starts to show up, but all grey, and there is a segfault. When running latest ArchLinux {i686 or ARMv7A} using the FreeType version included with MuseScore.git (ver *2.6.1*), then the segfault occurs in af_autofitter_load_glyph() line 332 of afmodule.c:
FT_Memory memory = module->root.library->memory;
since library is NULL, and gets deferenced. The next level up is in FT_Load_Glyph() at line 722 of ftobjs.c:
error = hinting->load_glyph( (FT_AutoHinter)hinter, slot, face->size, glyph_index, load_flags );
When running on ArchLinuxARMv7 using the latest FreeType *2.6.3*, then the segfault occurs in af_autofitter_loadglyph() in afmodule.c with the debugger error pointing to the af_property_set (line 332) here:
FT_DEFINE_SERVICE_PROPERTIESREC( af_service_properties, (FT_Properties_SetFunc)af_property_set, /* set_property */ (FT_Properties_GetFunc)af_property_get ) /* get_property */
and specifically inside next level at af_Load_Glypth() in ftobjs.c with arrow pointing at line 772:
FT_Face_Internal internal = face->internal;
and if I go to next level in disassembler, the debug arrow is pointing at this final line of:
0xaa305398 10 30 8d e5 str r3, [sp, #16] 0xaa30539c 08 30 9d e5 ldr r3, [sp, #8] 0xaa3053a0 05 20 a0 e1 mov r2, r5 0xaa3053a4 00 10 93 e5 ldr r1, [r3] 0xaa3053a8 48 58 fd eb bl 0xaa25b4d0 0xaa3053ac 40 00 50 e3 cmp r0, #64 ; 0x40
MScore outputted the following error to console:
(mscore:20989): Pango-WARNING **: failed to create cairo scaled font, expect ugly output. the offending font is 'FreeSans Bold 10' (mscore:20989): Pango-WARNING **: font_face status is: file not found (mscore:20989): Pango-WARNING **: scaled_font status is: file not found (mscore:20989): Pango-WARNING **: shaping failure, expect ugly output. shape-engine='PangoFcShapeEngine', font='FreeSans Bold 10', text='Scores'
It seems something to do with FreeType. As I mentioned in https://github.com/musescore/MuseScore/pull/2400 I can bypass this error if I use the QFileDialog::DontUseNativeDialog flag for all those file explorer popups. So that tells me error is only when using Native Dialogs.
NOTE: this error does not occur on my Windows 8.1 x86-64 machine when compile that latest master, apparently because Native File Dialogs are different in different Desktop Environments.
Comments
I also wanted to say that if I run shoogle's i686 AppImage:
https://bintray.com/artifact/download/shoogle/test/MuseScoreNightly-201…
Then I don't get the crash, and am able to browse those folders just fine. Maybe he is using a different library, or maybe there is some different setting for the (native?) file dialog.
2 things to consider.
1/ Native/Non native dialogs for Open file and Save file are controlled by a preference. We could (should?) use this preference for the "Choose directory" dialog.
2/ The freetype issue could be due to the fact that MuseScore ships a freetype version and Qt another one... However my understanding is that Native Dialog being Native, they are out of control of Qt drawing (at least it's the case for Qt on Mac and Windows)
Re (1), I can go ahead and make a pull request that will do just that: make all the preferences->choose folder dialogus use what comes Native boolean from the .ini file. EDIT: here is the issue I made: #99626: Make Preferences Choose Folder dialog obey the MuseScore.ini "nativeDialogs" boolean.
Re (2), I'm experimenting now with downloading different version of FreeType, replacing the files in muscore thridparty freetype dir, and recompiling to determine how error varies with verions. So far I tried the latest 2.6.3 and still get the error, in addition to the version currently in master.
Re (1), I've submitted PR 2406, which upon acceptance, will mean that won't have to encounter this bug when nativeDialogs=false (which is the factory reset state).
I just built latest 2.0.3 on my i686, and I ran it with nativeDialogs=true, and I can see the native file dialog open and run without issue. So I'm thinking this bug might be related to some commit that is in master but not in 2.0.3.
ADDENDUM: nativeDialogs=true also works fine in official arch linux 2.0.2, so clearly this is due to some commit in master that isn't in 2.0.3 or 2.0.2, since I'm doing this all on same machine. If anyone knows how to let me know here... (I asked in IRC, but I might not look at IRC).
I made it happen again on i686 git master arch linux, and this time I've attached the full backtrace:
core.mscore.1000.b6cf7d5e8a5a4e57b50.gdb-backtrace.txt
Note: crash happens on the main thread (thread 1), but after quite a few calls to a bunch of libraries (although note those stack levels #0 and #1 are in the MuseScore.git thirdparty repo "FreeType"):
just noting that I just redid the crash on arch linux armv7 using latest git master, but the strack trace is:
which while still in FreeType, is in a different line. I'm wondering if there is some unintentional memory overwritting going on, which is
the secret command to compare commits is
or
Do you have precise steps to reproduce the issue?
very old and lack of feedback