You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've recently introduced AppImage packaging with appimage-builder to 86Box/86Box. While the setup I came up with works perfectly on x86_64, armhf and aarch64, I run into a consistent segfault related to widechar file operations (used to load our 86box.cfg config file) on i386, reproduced on glibc 2.31 both provided by the system and the AppImage, and both Debug and Release versions of AppRun:
#
# 86Box v3.2 logfile, created 2022/02/13 16:35:56
#
# VM: 86Box
#
# Emulator path: /tmp/.mount_test.ABJfmNC/usr/local/bin/
# Userfiles path: /home/richard/86Box/
# ROM path: /home/richard/86Box/roms/
# Configuration file: /home/richard/86Box/86box.cfg
#
APPRUN_HOOK_DEBUG: fopen "/home/richard/86Box/86box.cfg"
APPRUN_HOOK_DEBUG: fopen "/home/richard/86Box/86box.cfg"
Thread 1 "86Box" received signal SIGSEGV, Segmentation fault.
0xf62d6e0a in _IO_getwline_info (fp=0x58eb9f30, buf=0xffff9d10 L"", n=1023, delim=10, extract_delim=1, eof=0x0) at iogetwline.c:58
58 iogetwline.c: No such file or directory.
(gdb) bt
#0 0xf62d6e0a in _IO_getwline_info (fp=0x58eb9f30, buf=0xffff9d10 L"", n=1023, delim=10, extract_delim=1, eof=0x0) at iogetwline.c:58
#1 0xf62d6f5a in _IO_getwline (fp=0x58eb9f30, buf=0xffff9d10 L"", n=1023, delim=10, extract_delim=1) at iogetwline.c:35
#2 0xf62d69f1 in fgetws (buf=buf@entry=0xffff9d10 L"", n=n@entry=1024, fp=fp@entry=0x58eb9f30) at iofgetws.c:53
#3 0x565f97c7 in config_read (fn=<optimized out>) at /86Box/src/config.c:331
#4 0x565ff725 in config_load () at /86Box/src/config.c:2063
#5 0x565f7eff in pc_init (argc=<optimized out>, argv=<optimized out>) at /86Box/src/86box.c:720
#6 0x569c89a4 in main (argc=<optimized out>, argv=0xffffc4f4) at /86Box/src/qt/qt_main.cpp:160
The relevant config_read function is here (line 303). Some debugging with gdb reveals that the segfault is caused by an access to fp->_wide_data, because the FILE structure returned by fopen is somehow bogus (I've had it end up in the middle of a Qt5-related string on other occasions):
If the config reading code is skipped (by 86box.cfg being absent), the config saving code (line 417) doesn't segfault, but the resulting 86box.cfg file ends up empty, because all calls to fwprintf return -1 (with no errno set) due to the bogus FILE. While debugging this issue, I recall inserting a standard non-wchar fprintf into that code, and that did work but fwprintf did not.
All this weird file behavior doesn't happen when the 86Box binary is executed without AppRun, either directly or through a manually-generated AppImage, or with AppRun on non-i386 architectures.
The text was updated successfully, but these errors were encountered:
AppRun uses libapprun_hooks to intercept libc functions that takes a file path as argument to allow patching it at runtime. The bug should be there. I'm currently involved on a big fix of AppRun so it would take me a week or two to get to this issue. But if you want to jump into debugging and patching the code I could assist you.
Small update: this was apparently fixed in our project by defining _FILE_OFFSET_BITS=64, _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE on i386 builds. I'm keeping this issue open, though, as it could theoretically affect anything not compiled with 64-bit file support.
I've recently introduced AppImage packaging with appimage-builder to 86Box/86Box. While the setup I came up with works perfectly on
x86_64
,armhf
andaarch64
, I run into a consistent segfault related to widechar file operations (used to load our86box.cfg
config file) oni386
, reproduced on glibc 2.31 both provided by the system and the AppImage, and both Debug and Release versions of AppRun:The relevant
config_read
function is here (line 303). Some debugging with gdb reveals that the segfault is caused by an access tofp->_wide_data
, because theFILE
structure returned byfopen
is somehow bogus (I've had it end up in the middle of a Qt5-related string on other occasions):If the config reading code is skipped (by
86box.cfg
being absent), the config saving code (line 417) doesn't segfault, but the resulting86box.cfg
file ends up empty, because all calls tofwprintf
return-1
(with noerrno
set) due to the bogusFILE
. While debugging this issue, I recall inserting a standard non-wcharfprintf
into that code, and that did work butfwprintf
did not.All this weird file behavior doesn't happen when the 86Box binary is executed without AppRun, either directly or through a manually-generated AppImage, or with AppRun on non-
i386
architectures.The text was updated successfully, but these errors were encountered: