main thread random context doesn't reinitialize correctly with non-weak source
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 停滞
- 技术栈
- c
调研方向
从 src/init.c 中的 _mi_auto_process_init 开始,跟踪对 mi_heap_main_init 和 _mi_random_reinit_if_weak 的调用,然后检查 src/random.c 中 mi_random_init_ex 和 chacha_init 附近的代码。检查 Windows 的非共享库初始化路径,并验证主线程的随机上下文能够正确重新初始化,而不会在线程初始化期间触发有问题的 BCrypt 操作。
由索引模型根据 Issue 内容生成。
描述
TLDR is that _mi_auto_process_init attempts to reseed the main thread's random ctx (which would cause BCrypt to get loaded there) but there's a bug preventing that from working.
Starting point:
https://github.com/microsoft/mimalloc/blob/09a27098aa6e9286518bd9c74e6ffa7199c3f04e/src/init.c#L580
_mi_auto_process_init calls mi_heap_main_init which on _WIN32 && !MI_SHARED_LIB builds calls _mi_random_init_weak for bcrypt-related reasons.
Then, we call _mi_random_reinit_if_weak at the end of _mi_auto_process_init
BUT, that will never actually do anything.
Why? The mi_random_ctx_t weak bool will always be false after any call to mi_random_init_ex.
Why? At the end of mi_random_init_ex, for either the weak or normal path, we call chacha_init.
And what does that guy do? Memsets the entire mi_random_ctx_t to zero, wiping out the weak bool.
We discovered this when we saw a thread was doing the mimalloc BCrypt-related initialization (e.g. LoadLibrary) during the initialization of a thread, which involved calling LoadLibrary a couple times and holding an internal BCrypt critical section while the thread initialization has the loader lock held (because the root calloc in that new thread is inside of __vcrt_getptd_noexit). So it seems, given the above mentioned code, that it's not intended that we'd be leaving the main thread's initialization without initializing the BCrypt stuff?
- 主要语言
- C
- 星标
- 13.6k
- 派生
- 1.2k
- 平均合并
- 18 小时 12 分钟
- 30 天内合并 PR
- 20
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
microsoft/mimalloc 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
Building mimalloc with `-Wundef` compiler flag logs many warnings on undefined macros可能已有人在做 @vstinner 于 1 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 64/100
microsoft/mimalloc#1506 · 5 条评论 ·
维护者通常 1 天内回复
-
stale
难度 2/5 1-3 小时 新手友好度 74/100
microsoft/mimalloc#1113 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
microsoft/mimalloc#886 · 4 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 64/100
microsoft/mimalloc#368 · 1 条评论 ·
维护者通常 1 天内回复
查看 microsoft/mimalloc 的全部 Issue
相似的 Issue
-
needs triage
难度 2/5 1-3 小时 新手友好度 70/100
389ds/389-ds-base#8157 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 67/100
coolsnowwolf/lede#14305 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
Needs-Triage
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 2 天内回复