Skip to content

[6012] 修复对原子节点调用 tree-children 引发段错误崩溃 - #4697

Merged
da-liii merged 1 commit into
mainfrom
da/6012/fix_atomic_tree_children
Oct 10, 2026
Merged

da-liii merged 1 commit into
mainfrom
da/6012/fix_atomic_tree_children

Conversation

@da-liii

@da-liii da-liii commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

变更描述

在底层核心类 lolly_tree_rep 中,原子节点与复合节点通过 union 结构复用内存空间(op == 0 为原子节点的 string label,op > 0 为复合节点的 array<tree> a)。原先 glue_tree.lua 中将 Scheme 过程 tree-children 直接绑定至 C++ A(t),当输入为原子节点时,直接将 string label 内存区域解释为 array<tree>,引发非法地址解引用导致 SIGSEGV 崩溃。

修复方案

  1. 在 src/Scheme/L4/glue_tree_extra.hpp 中实现 tree_children(tree t) 包装函数,通过 is_atomic(t) 进行前置防御检查:若为原子节点安全返回空数组 array<tree>(),否则返回 A(t);
  2. 在 src/Scheme/L4/glue_tree.lua 中将 tree-children 的 cpp_name 更新为 tree_children;
  3. 在 TeXmacs/progs/kernel/library/tree-test.scm 中补充针对原子节点调用 tree-children 返回空列表的单元测试断言。

Fixes #4695

@MoonL79 MoonL79 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@da-liii
da-liii merged commit d8b7943 into main Oct 10, 2026
6 checks passed
@da-liii
da-liii deleted the da/6012/fix_atomic_tree_children branch October 10, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Headless 模式问题汇总:原子节点 tree-children 段错误、会话同步求值崩溃、光标与提示符回退异常

2 participants