neomacs icon indicating copy to clipboard operation
neomacs copied to clipboard

[Bug]: no window, then crash

Open definepi opened this issue 1 week ago • 6 comments

Bug summary

本来第一次还能正常运行一下的,不记得做了什么操作,卡死后我杀了进程,再次打开就卡住,只能看到KDE任务栏有出现应用的图标,但没有看到emacs窗口。再次杀掉重新打开也一样。

好兄弟,给你带上土特产: neomacs-debug.zip

Steps to reproduce

No response

Expected behavior

No response

Neomacs --version output

Neomacs 0.0.21
Git commit: 7b3fa9d698ba41fdbabccd9bd3e547a0afa7164a
Source date: 2026-11-22T03:37:02.000000000-05:00
Build: release-pgo for x86_64-unknown-linux-gnu with rustc 1.96.1
Standalone Rust binary for Neomacs (no C dependency)

Platform

Linux (Wayland)

Install source

Prebuilt release asset (downloaded from Releases)

Extra context

No response

definepi avatar Nov 23 '26 01:11 definepi

感谢反馈和日志,日志非常有用!(English below.)

日志里看到的情况(这一次启动是"没有窗口"的那次):

  • 窗口在 00:54:10 就创建了,Lisp 侧(Doom 配置)0.8 秒就加载完了,一直在正常等待输入。
  • 卡住的是 GPU 初始化:Neomacs 默认选了高性能显卡,也就是 Quadro P620,走的是 Mesa 26.2.7 的 NVK(nouveau)驱动。
    • 枚举显卡用了约 65 秒,创建设备又用了约 115 秒。
    • 期间一帧都没画出来,所以 Wayland 窗口一直没有映射,只能看到任务栏图标。
  • 设备终于建好后,第一帧还没画完 GPU 设备就丢失了(wgpu device lost)。
    • Neomacs 没有正确处理这个情况,直接崩溃了(panic)。这是我们的 bug,会修。
    • 之后释放 GPU 资源又花了 80 秒。

我们的推测(日志无法完全证实):第一次"卡死"可能是 nouveau/NVK 上的一次 GPU hang,强制结束进程后显卡驱动一直处于异常状态,所以之后每次启动都会卡住。Neomacs 自身没有会导致"之后每次都打不开"的缓存文件。

能否帮忙试一下:

  1. 重启电脑后再启动一次,看是否恢复成第一次那样能正常打开。
  2. 绕开 NVK,用 Intel 核显:
    WGPU_BACKEND=gl ./Neomacs*.AppImage
    
    或者:
    VK_DRIVER_FILES=/usr/share/vulkan/icd.d/intel_icd.x86_64.json ./Neomacs*.AppImage
    
  3. 启动失败后贴一下:
    sudo dmesg | grep -iE 'nouveau|nvk|gr:|fifo'
    vulkaninfo --summary
    uname -r
    

我们这边会修的:

  • GPU 设备丢失时绝不 panic:放弃当前帧并恢复,必要时换用下一块显卡(比如核显)。
  • 获取显卡时间过长时给出提示,而不是一直没有窗口。
  • 设备丢失后不再等待漫长的资源释放。

English summary. This run is a "no window" relaunch.

  • What stalled: Lisp and Doom were fine. GPU startup on the default high-performance adapter (Quadro P620 on Mesa 26.2.7 NVK) took about 65 s to enumerate and about 115 s to create the device, so no frame was ever presented and the window never mapped.
  • The crash: the device was then lost on the first frame, and Neomacs panicked instead of recovering. That part is our bug and will be fixed.
  • Why every relaunch fails: we suspect the first freeze wedged the NVK driver until reboot. Nothing Neomacs persists would explain it.
  • Please try:
    1. a reboot;
    2. WGPU_BACKEND=gl or VK_DRIVER_FILES=…/intel_icd.x86_64.json to use the Intel iGPU;
    3. post dmesg | grep -iE 'nouveau|nvk|gr:|fifo', vulkaninfo --summary and uname -r.

eval-exec avatar Nov 23 '26 01:11 eval-exec

加上 WGPU_BACKEND=gl 确实可以正常显示出窗口了。顺便把没指定Intel时的失败的dmesg给你:

[421327.901002] nouveau 0000:01:00.0: timeout
[421327.901003] WARNING: drivers/gpu/drm/nouveau/nvkm/engine/fifo/nv50.c:228 at nv50_runl_wait+0xe6/0x100 [nouveau], CPU#1: gpu-adapters/2148298
[421327.901235]  snd_sof_pci snd_sof_xtensa_dsp snd_sof snd_sof_utils snd_soc_acpi_intel_match snd_soc_acpi_intel_sdca_quirks soundwire_generic_allocation snd_soc_sdw_utils snd_soc_acpi soundwire_bus intel_rapl_msr snd_soc_sdca intel_uncore_frequency crc8 intel_uncore_frequency_common snd_soc_avs snd_soc_hda_codec snd_hda_ext_core intel_tcc_cooling snd_hda_codec btusb x86_pkg_temp_thermal snd_hda_core intel_powerclamp btmtk btrtl coretemp snd_intel_dspcfg iwlmvm spi_nor vfat btbcm iTCO_wdt rapl snd_intel_sdw_acpi fat btintel ee1004 intel_pmc_bxt snd_hwdep mtd mei_pxp mei_hdcp nouveau intel_cstate i915 mac80211 snd_soc_core bluetooth processor_thermal_device_pci_legacy snd_ctl_led snd_compress gpu_sched intel_uncore processor_thermal_device libarc4 processor_thermal_wt_hint intel_pmc_core drm_gpuvm ac97_bus pcspkr think_lmi mxm_wmi platform_temperature_control intel_wmi_thunderbolt pmt_telemetry snd_pcm_dmaengine drm_ttm_helper drm_buddy firmware_attributes_class wmi_bmof processor_thermal_soc_slider snd_pcm thinkpad_acpi
[421327.901326] RIP: 0010:nv50_runl_wait+0xec/0x100 [nouveau]
[421327.901480]  nv50_runl_update+0x2b9/0x350 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.901606]  ? nvkm_uchan_new+0x14b/0x350 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.901730]  nvkm_runl_update_locked+0x34/0x60 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.901855]  nvkm_chan_insert+0xc5/0x150 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.901978]  nvkm_uchan_init+0x3c/0x50 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.902098]  nvkm_object_init+0x4d/0x140 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.902183]  ? nvkm_subdev_unref+0x1e/0x40 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.902267]  ? nvkm_engine_unref+0x22/0x40 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.902348]  nvkm_ioctl_new+0x176/0x250 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.902434]  ? __pfx_nvkm_udevice_child_new+0x10/0x10 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.902561]  nvkm_ioctl+0xb0/0x130 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.902662]  nvif_object_ctor+0x128/0x1e0 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.902740]  nouveau_channel_ctor+0x531/0x7f0 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.902849]  nouveau_channel_new+0x42/0x610 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.902955]  ? nvif_fifo_runlist+0x142/0x1d0 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.903036]  ? nouveau_abi16_ioctl_channel_alloc+0xd0/0x490 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.903142]  nouveau_abi16_ioctl_channel_alloc+0x13b/0x490 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.903247]  ? __pfx_nouveau_abi16_ioctl_channel_alloc+0x10/0x10 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.903357]  ? __pfx_nouveau_abi16_ioctl_channel_alloc+0x10/0x10 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]
[421327.903469]  nouveau_drm_ioctl+0x58/0xc0 [nouveau 6c899df52e08798f617e2f72d6b0d4720a8b5223]

definepi avatar Nov 23 '26 02:11 definepi

谢谢!这个 dmesg 很关键。

nouveau ... timeout / nv50_runl_wait 的调用栈显示:Neomacs 的 gpu-adapters 线程在探测 Quadro P620(nouveau/NVK)时,内核 nouveau 驱动创建 GPU 通道超时。卡住的根源在驱动里,然后才出现设备丢失。这也说明为什么 WGPU_BACKEND=gl(走 Intel 核显)就正常了。

在修复发布前,请先继续用 WGPU_BACKEND=gl。

我们正在做的修复:

  • GPU 设备丢失时不再 panic;
  • 启动时如果某块显卡失败或丢失,自动换下一块(比如 Intel 核显);
  • 显卡探测或创建超过 10 秒时给出明确提示,说明是哪个驱动,以及可用的环境变量。

English summary.

  • Your dmesg: the kernel nouveau driver times out creating a channel (nv50_runl_wait in nvkm_uchan_new) while our gpu-adapters thread probes the Quadro P620. The stall is in the driver, and the device loss follows from it.
  • Workaround until the fix ships: keep WGPU_BACKEND=gl.
  • The fix:
    • no panic on device loss;
    • automatic fallback to the next adapter (the Intel iGPU here) when one fails during startup;
    • a clear warning naming the driver once GPU setup takes more than 10 s.

eval-exec avatar Nov 23 '26 03:11 eval-exec

修复已合入 main(28e3c74687),尚未发布到正式版本。

改动:

  • GPU 设备丢失时不再 panic。
  • 启动时,如果某块显卡在首帧之前失败,会被排除并尝试下一块。所有硬件都失败时,才回退到软件渲染。
  • GPU 启动超过 10 秒时会打印警告,说明卡在哪个阶段(枚举或创建设备),并提示 WGPU_BACKEND=gl 或 NEOMACS_GPU=integrated。
  • 设备丢失后退出时,不再等待驱动释放设备。

说明:你的 dmesg 显示卡住发生在内核 nouveau 驱动创建 GPU 通道的过程中(枚举阶段)。这一步发生在驱动内部,Neomacs 无法中断它。所以在这台机器上,WGPU_BACKEND=gl 仍然是推荐的做法。下一个补丁会在枚举阶段的警告里直接给出这个提示。

如果方便,请用最新的 main 构建试一下,并告诉我们结果。

eval-exec avatar Nov 23 '26 12:11 eval-exec

The crash paths described here are fixed on main (cab08eb094): 28e3c74687, ac546e8b83, 7c8e993bc6.

Note the underlying nouveau kernel hang is external to Neomacs — if the machine still hangs before the editor starts, that will reproduce independently of us. What should be gone is the crash-with-no-window behaviour once the driver does return.

eval-exec avatar Nov 25 '26 21:11 eval-exec

Closing as fixed on main (8471a2c0d1).

Every Neomacs defect path observed in the attached neomacs-debug.log (from 0.0.21 7b3fa9d698) maps to landed commits on main:

  1. 00:54:10 -> 00:55:15 (+65.0 s) Vulkan enumeration stall (external kernel nouveau nv50_runl_wait timeout in dmesg, uninterruptible inside the kernel):
    • dea4f6faa9, b75e351362, 28e3c74687, 53a6392c99 — 10-second EventTime startup watch logs a clear warning naming WGPU_BACKEND=gl and VK_DRIVER_FILES during enumeration, and the adapter/driver during device creation.
  2. 00:55:15 -> 00:57:11 (+115.5 s) Quadro P620 device creation stall / pre-present failure:
    • 2e758709ae, cc7bb04ca7 — excludes an adapter that fails before the first present and automatically falls back to the next surface-capable hardware adapter (Intel UHD Graphics here) before CPU fallback.
  3. 00:57:11.408 first-frame wgpu device lost panic (wgpu::util::DeviceExt::create_buffer_init -> MapRangeError on 'Immutable draw parameters'):
    • 5c33a7362a — replaced create_buffer_init in crates/neomacs-renderer-wgpu/src/renderer/draw/parameters.rs with create_initialized_buffer, which returns Result<wgpu::Buffer, DeviceLost> and abandons the frame cleanly.
    • Workspace-wide audit on 8471a2c0d1 (production code, tests, and examples): zero create_buffer_init call sites remain anywhere in the repository. Both remaining mapped_at_creation: true sites (crates/neomacs-renderer-wgpu/src/renderer/draw/parameters.rs:36-44 and crates/neomacs-video/src/sampling.rs:1266-1268) and both production get_mapped_range() readback sites (crates/neomacs-display-runtime/src/render_thread/surface_readback.rs:153, crates/neomacs-renderer-wgpu/src/gpu_frame_timing.rs:336) return/match Result errors without panicking.
  4. 00:57:11 -> 00:58:31 (+80.5 s) exit hang dropping the lost device:
    • ac546e8b83, 7c8e993bc6 — abandon lost GPU devices/contexts on exit and recovery instead of dropping into the wedged driver.

Verified on 8471a2c0d1: all 38 gpu_startup, device_loss, toolbar_reloads_all_required_icons_after_device_loss, and destroyed_device_abandons_the_draw_parameter_frame regression tests pass.

If you still see a crash or unwarned hang on a build from 8471a2c0d1 or later (or the next release), please reopen with a fresh debug log — note that on a wedged kernel nouveau driver, WGPU_BACKEND=gl remains the workaround for the in-kernel enumeration delay.

eval-exec avatar Nov 26 '26 05:11 eval-exec