From 42312a39b1f9467a87eb86dc0759aed07e6b149d Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Thu, 27 Aug 2026 00:55:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(desktop):=20mm.malloc=20=E6=98=BE=E5=BC=8F?= =?UTF-8?q?=20CUInt64T=20=E5=8F=82=E6=95=B0=E8=A7=84=E9=81=BF=E8=A3=B8?= =?UTF-8?q?=E5=90=8D=E5=9B=9E=E9=80=80=20i32=20=E5=8F=82=E6=95=B0=EF=BC=88?= =?UTF-8?q?bg=5Frow=5Fbuf=20=E6=94=B6=E5=88=B0=200x0=EF=BC=89=EF=BC=9Bfat3?= =?UTF-8?q?2=20dir=5Fget=5Fentry=5Finfo=20=E5=8A=A0=20win=20=E7=BC=93?= =?UTF-8?q?=E5=86=B2=E5=86=85=E5=AE=B9=E8=AF=8A=E6=96=AD=EF=BC=88=E6=A0=B9?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=E6=98=BE=E7=A4=BA=20(None)=20size=3D523360?= =?UTF-8?q?=E3=80=81dir=5Ffind=20offset=3D0=20=E5=A4=B1=E8=B4=A5=E7=96=91?= =?UTF-8?q?=E4=BC=BC=20win=20=E6=B1=A1=E6=9F=93=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VKernel/Kernel/drivers/fs/fat32/fat32_types.vp | 9 +++++++++ VKernel/Kernel/services/desktop.vp | 10 ++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp b/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp index 7dd17cb..29a0755 100644 --- a/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp +++ b/VKernel/Kernel/drivers/fs/fat32/fat32_types.vp @@ -776,6 +776,15 @@ class volinfo: def dir_get_entry_info(self, dp: dirobj | t.CPtr, info: fileinfo | t.CPtr, lfn_buf: t.CUInt16T | t.CPtr) -> FRESULT: res: FRESULT = self._read_entry_from_dir(dp) if res != FRESULT.FR_OK: return FRESULT.FR_DISK_ERR + # [DIAG] 定位 win 缓冲污染:磁盘根目录 off=0 应为 "APP" attr=0x10 size=0, + # 但运行时显示 (None) size=523360 → win 内容与磁盘不符。 + _dge: t.CArray[t.CChar, 128] + viperlib.snprintf(c.Addr(_dge), 128, + "[dge] off=%lu w0=%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x attr=%02x size=%lu winsect=%lx\n", + dp.offset, self.win[0], self.win[1], self.win[2], self.win[3], + self.win[4], self.win[5], self.win[6], self.win[7], self.win[8], + self.win[9], self.win[10], self.win[11 + 0], _read32(c.Addr(self.win[0]), 28), self.winsect) + serial.puts(c.Addr(_dge)) entry_offset_in_sector: t.CUInt32T = (dp.offset % (512 / ENTRY_SIZE)) * ENTRY_SIZE off: t.CUInt32T = entry_offset_in_sector raw_attr: t.CUInt8T = self.win[off + 11] diff --git a/VKernel/Kernel/services/desktop.vp b/VKernel/Kernel/services/desktop.vp index 8a18d73..2699ae8 100644 --- a/VKernel/Kernel/services/desktop.vp +++ b/VKernel/Kernel/services/desktop.vp @@ -1848,14 +1848,14 @@ def start(fb_ptr: t.CVoid | t.CPtr, w: t.CInt, h: t.CInt, pitch: t.CInt = 0) -> _prev_cursor_x = _cursor_x _prev_cursor_y = _cursor_y - _dirty_rows = mm.malloc(h) + _dirty_rows = mm.malloc(t.CUInt64T(h)) if _dirty_rows: string.memset(_dirty_rows, 0, h) else: serial.puts("[desktop] dirty_rows malloc FAILED\n") return None - _back_fb = mm.malloc(w * h * 4) + _back_fb = mm.malloc(t.CUInt64T(w) * t.CUInt64T(h) * 4) _dbg_bf: t.CArray[t.CChar, 96] viperlib.snprintf(c.Addr(_dbg_bf), 96, "[dbg] back_fb ret=0x%lx w=%d h=%d\n", t.CUInt64T(_back_fb), w, h) serial.puts(c.Addr(_dbg_bf)) @@ -1865,7 +1865,7 @@ def start(fb_ptr: t.CVoid | t.CPtr, w: t.CInt, h: t.CInt, pitch: t.CInt = 0) -> serial.puts("[desktop] back_fb malloc FAILED\n") return None - _row_buf = mm.malloc(w * 4) + _row_buf = mm.malloc(t.CUInt64T(w) * 4) _dbg_rb: t.CArray[t.CChar, 96] viperlib.snprintf(c.Addr(_dbg_rb), 96, "[dbg] row_buf ret=0x%lx\n", t.CUInt64T(_row_buf)) serial.puts(c.Addr(_dbg_rb)) @@ -1874,7 +1874,9 @@ def start(fb_ptr: t.CVoid | t.CPtr, w: t.CInt, h: t.CInt, pitch: t.CInt = 0) -> else: serial.puts("[desktop] row_buf malloc FAILED!\n") - _bg_row_buf = mm.malloc(w * 4) + # mm.malloc(w*4) 走裸名回退生成 call @malloc(i32),形参 i64 不匹配(第 4 次 + # 调用 RAX 返回值被破坏收到 0)。显式 CUInt64T 让参数按 i64 传递。 + _bg_row_buf = mm.malloc(t.CUInt64T(w) * 4) _dbg_br: t.CArray[t.CChar, 96] viperlib.snprintf(c.Addr(_dbg_br), 96, "[dbg] bg_row_buf ret=0x%lx\n", t.CUInt64T(_bg_row_buf)) serial.puts(c.Addr(_dbg_br))