cling failure when accessing `std::map` elements from Python
维护者通常 1 天内回复
@guitargeek 已经在做这个了。
开始于 2026年1月19日。
评估
这个 Issue 还没有评估数据。
描述
Check duplicate issues.
- Checked for duplicates
Description
Consider the following program
import ROOT
ROOT.gInterpreter.Declare(r"""
struct S{};
std::map<std::string, std::vector<std::unique_ptr<S>>> mymap;
mymap["a"] = std::vector<std::unique_ptr<S>>();
""")
# For some reason, uncommenting the following line will prevent the program from crashing
# print(ROOT.mymap)
for key, value in ROOT.mymap:
print(key, value)
Running this program in master shows no issues:
$: python test_map.py
a {}
But I suspect there is a real problem hidden in this code. By applying this simple patch https://github.com/root-project/root/pull/20946, the same program crashes
*** Break *** illegal instruction
[...]
make_dtor_wrapperFailed to compile
==== SOURCE BEGIN ====
__attribute__((used)) extern "C" void __dtor_0(void* obj, unsigned long nary, int withFree)
{
if (withFree) {
if (!nary) {
delete (std::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<std::unique_ptr<S, std::default_delete<S> >, std::allocator<std::unique_ptr<S, std::default_delete<S> > > > > >*) obj;
}
else {
delete[] (std::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<std::unique_ptr<S, std::default_delete<S> >, std::allocator<std::unique_ptr<S, std::default_delete<S> > > > > >*) obj;
}
}
else {
typedef std::_Rb_tree_iterator<std::pair<const std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::vector<std::unique_ptr<S, std::default_delete<S> >, std::allocator<std::unique_ptr<S, std::default_delete<S> > > > > > Nm;
if (!nary) {
((Nm*)obj)->~Nm();
}
else {
do {
(((Nm*)obj)+(--nary))->~Nm();
} while (nary);
}
}
}
I attach the full stacktrace here
Something that looks odd is the presence of const std::basic_string in part of the output from above, while the std::map I create uses just std::basic_string, I don't know if it's related to the issue.
Reproducer
See above
ROOT version
Master with patch https://github.com/root-project/root/pull/20946
Installation method
Build from source
Operating system
Linux
Additional context
No response
- 主要语言
- C++
- 星标
- 3.3k
- 派生
- 1.6k
- 平均合并
- 2 天 16 小时
- 30 天内合并 PR
- 194
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
root-project/root 的其他 Issue
-
thisroot.sh: wrong ROOTSYS in zsh when the shell's command line has a newline可能已有人在做 @dpiparo 于 3 天前认领。 未关闭bug in:Build System
难度 2/5 1-3 小时 新手友好度 86/100
root-project/root#23746 · 已指派 1 人 ·
维护者通常 1 天内回复
-
[tmva][sofie] Inputs of unsupported type (e.g. float16) give code that does not compile instead of an error可能已有人在做 @lmoneta 于 12 天前认领。 未关闭AI-Assisted bug in:SOFIE
难度 2/5 1-3 小时 新手友好度 65/100
root-project/root#23655 · 已指派 1 人 ·
维护者通常 1 天内回复
-
bug
难度 3/5 1-2 天 新手友好度 71/100
root-project/root#23790 ·
维护者通常 1 天内回复
-
bug in:Core Libraries
难度 4/5 3-5 天 新手友好度 48/100
root-project/root#23777 ·
维护者通常 1 天内回复
-
`TChain::GetEntries` internal caching ineffective?可能已有人在做 @pcanal 于 5 天前认领。 未关闭improvement in:TTree
root-project/root#23738 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 root-project/root 的全部 Issue
相似的 Issue
-
enhancement GUI maintainer-review
难度 2/5 1-3 小时 新手友好度 66/100
aethersdr/AetherSDR#6681 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
Bug
难度 2/5 1-3 小时 新手友好度 70/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
area: ui bug good first issue P2: medium value: medium
难度 2/5 1-3 小时 新手友好度 75/100
patrick-hudson/put.gd-desktop#366 ·
维护者通常 1 天内回复