DisplayMode.name is NULL which causes X11 to segfault
Here is the shortened log with debug builds of xorg-server and xf86-video-openchrome(tag 0.6.604 - https://cgit.freedesktop.org/openchrome/xf86-video-openchrome/commit/?h=main&id=40a341dc8aaeba1150f8bde43e4e33e506baf75d ) with what I believe to be the meaningful lines from it:
X.Org X Server 1.21.1.8
X Protocol Version 11, Revision 0
Current Operating System: Linux 5.15.118-yocto-standard #1 SMP PREEMPT Thu Jun 22 18:18:26 UTC 2023 x86_64
Kernel command line: mitigations=off splash console=tty0,115200n8 console=ttyS0,115200n8 console=ttyO0,115200n8 console=ttyAMA0,115200n8 rootwait
<snip>
Layout section parsed
Found 1 screens in the layout section Default Layout
Found 0 inactive devices in the layout section Default Layout
Found 0 input devices in the layout section Default Layout
ACPI: OSPMOpen called
ACPI: Opening device
LoaderOpen(/usr/lib/xorg/modules/extensions/libglx.so)
LoaderOpen(/usr/lib/xorg/modules/drivers/openchrome_drv.so)
openchrome: card at 0:1:0 is claimed by a Device section
<...>
Sequencer[0x02] = 0x0f
Sequencer[0x03] = 0x00
Sequencer[0x04] = 0x0e
Mapping VGAMem
(EE)
(EE) Backtrace:
(EE) 0: Xorg (xorg_backtrace+0x4c) [0x55d5e4800b54]
(EE) 1: Xorg (0x55d5e46b8000+0x14c739) [0x55d5e4804739]
(EE) 2: /lib/libc.so.6 (0x7facda098000+0x3f100) [0x7facda0d7100]
(EE) 3: /lib/libc.so.6 (0x7facda098000+0x175b2e) [0x7facda20db2e]
(EE) 4: Xorg (xf86ProbeOutputModes+0x5e2) [0x55d5e4851bf4]
(EE) 5: Xorg (xf86InitialConfiguration+0x12f) [0x55d5e4851e04]
(EE) 6: /usr/lib/xorg/modules/drivers/openchrome_drv.so (0x7facd9909000+0x1cbcf) [0x7facd9925bcf]
(EE) 7: /usr/lib/xorg/modules/drivers/openchrome_drv.so (0x7facd9909000+0xff30) [0x7facd9918f30]
(EE) 8: Xorg (InitOutput+0x5a0) [0x55d5e48227a1]
(EE) 9: Xorg (0x55d5e46b8000+0x6d81d) [0x55d5e472581d]
(EE) 10: Xorg (0x55d5e46b8000+0x1d157a) [0x55d5e488957a]
(EE) 11: /lib/libc.so.6 (0x7facda098000+0x2c864) [0x7facda0c4864]
(EE) 12: /lib/libc.so.6 (__libc_start_main+0x78) [0x7facda0c490b]
(EE) 13: Xorg (_start+0x25) [0x55d5e46e8bd5]
Tracing the segfault leads to the following lines:
xorg-server-21.1.8/hw/xfree86/modes/xf86Crtc.c :
1850: for (mode = output->probed_modes; mode; mode = mode->next) {
1851: if (!strcmp(preferred_mode, mode->name)) {
1852: if (mode != output->probed_modes) {
1851 in ../xorg-server-21.1.8/hw/xfree86/modes/xf86Crtc.c
(gdb) step
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7622b2e in ?? () from /lib/libc.so.6
The DisplayMode struct is correctly filled however the .name member is NULL which causes strcmp in hw/xfree86/modes/xf86Crtc.c to segfault:
$32 = (DisplayModePtr) 0x555555838c90
(gdb) p *output_modes
$33 = {prev = 0x0, next = 0x0, name = 0x0, status = MODE_OK, type = 72, Clock = 38250, HDisplay = 800, HSyncStart = 832, HSyncEnd = 912, HTotal = 1024, HSkew = 0, VDisplay = 600, VSyncStart = 603, VSyncEnd = 607, VTotal = 624,
VScan = 0, Flags = 6, ClockIndex = 0, SynthClock = 0, CrtcHDisplay = 800, CrtcHBlankStart = 800, CrtcHSyncStart = 832, CrtcHSyncEnd = 912, CrtcHBlankEnd = 1024, CrtcHTotal = 1024, CrtcHSkew = 0, CrtcVDisplay = 600,
CrtcVBlankStart = 600, CrtcVSyncStart = 603, CrtcVSyncEnd = 607, CrtcVBlankEnd = 624, CrtcVTotal = 624, CrtcHAdjusted = 0, CrtcVAdjusted = 0, PrivSize = 0, Private = 0x0, PrivFlags = 0, HSync = 0, VRefresh = 59.8614044}
The xf86-video-openchrome driver previously was working fine with xorg-server 1.20.8 and the following xorg.conf:
Section "Files"
FontPath "/usr/share/fonts/ttf"
ModulePath "/usr/lib/xorg/modules"
EndSection
Section "ServerFlags"
Option "DontZap"
EndSection
Section "Monitor"
Identifier "VGA-1"
Option "Enable" "false"
Option "ignore" "true"
EndSection
Section "Monitor"
Identifier "FP-1"
Option "Enable" "true"
Option "DPMS" "true"
EndSection
Section "Device"
Identifier "Via Graphics"
Driver "openchrome"
Option "AccelMethod" "exa"
Option "ExaScratchSize" "8192"
Option "MaxDRIMem" "16384"
Option "MigrationHeuristic" "greedy"
EndSection
Section "Screen"
Identifier "screen"
Device "Via Graphics"
Monitor "FP-1"
DefaultDepth 24
Subsection "Display"
ViewPort 0 0
Modes "800x600@59.86"
Depth 24
EndSubsection
EndSection
Section "ServerLayout"
Identifier "Default Layout" Screen 0 "screen" 0 0
Option "StandbyTime" "0"
Option "SuspendTime" "0"
Option "OffTime" "0"
Option "BlankTime" "0"
EndSection
The following patch adds name of the mode:
From: Edi Feschiyan <edi.feschiyan@konsulko.com>
Date: Wed, 30 Aug 2023 13:29:38 +0300
Subject: [PATCH] xf86-video-openchrome: fill mode name
Fill Mode->name to prevent X11 from crashing due to missing
DisplayMode.name member
Signed-off-by: Edi Feschiyan <edi.feschiyan@konsulko.com>
Signed-off-by: Tim Orling <tim.orling@konsulko.com>
---
src/via_fp.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/via_fp.c b/src/via_fp.c
index f4c24f3..7caae39 100644
--- a/src/via_fp.c
+++ b/src/via_fp.c
@@ -1104,6 +1104,8 @@ via_fp_get_modes(xf86OutputPtr output)
VIAPtr pVia = VIAPTR(pScrn);
VIADisplayPtr pVIADisplay = pVia->pVIADisplay;
VIAFPPtr pVIAFP = (VIAFPPtr) output->driver_private;
+ const int MODENAMEMAXLEN = 32;
+ char tmpstr[MODENAMEMAXLEN];
DEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"Entered via_fp_get_modes.\n"));
@@ -1137,6 +1139,8 @@ via_fp_get_modes(xf86OutputPtr output)
pDisplay_Mode->CrtcVBlankEnd = max(pDisplay_Mode->CrtcVSyncEnd, pDisplay_Mode->CrtcVTotal);
pDisplay_Mode->CrtcHBlankStart = min(pDisplay_Mode->CrtcHSyncStart, pDisplay_Mode->CrtcHDisplay);
pDisplay_Mode->CrtcHBlankEnd = max(pDisplay_Mode->CrtcHSyncEnd, pDisplay_Mode->CrtcHTotal);
+ snprintf(&tmpstr, MODENAMEMAXLEN, "%dx%d@%f", pDisplay_Mode->HDisplay, pDisplay_Mode->VDisplay, pDisplay_Mode->VRefresh);
+ pDisplay_Mode->name = strndup(&tmpstr, MODENAMEMAXLEN);
pDisplay_Mode->type = M_T_DRIVER | M_T_PREFERRED;
} else {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,