Repository navigation
[6012] 修复对原子节点调用 tree-children 引发段错误崩溃 - #4697
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
变更描述
在底层核心类
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 崩溃。修复方案
src/Scheme/L4/glue_tree_extra.hpp中实现tree_children(tree t)包装函数,通过is_atomic(t)进行前置防御检查:若为原子节点安全返回空数组array<tree>(),否则返回A(t);src/Scheme/L4/glue_tree.lua中将tree-children的cpp_name更新为tree_children;TeXmacs/progs/kernel/library/tree-test.scm中补充针对原子节点调用tree-children返回空列表的单元测试断言。Fixes #4695