[BUG] TextureSystem: sample with gray_to_rgb possible crash if there are filesystem errors
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 38/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- cpp
调研方向
从 TextureSystemImpl::texture 开始,跟踪 ImageSpec 引用经过 sample_bilinear、ImageCacheImpl::find_tile 和 ImageCacheFile::mark_broken 的过程。使用文件系统打开失败的情况复现 UDIM 路径,然后验证灰色通道填充不再访问已失效的数据,并确认正常的纹理采样保持不变。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Been playing around with TextureSystem, and (for other reasons that I'm looking into) there have been spurious filesystem errors (due to too many open files - without setting max_open_files_strict in my use case the actual opened file count went way over the max_open_files of 100, and up to 510, at which point Windows MSVC runtime says "nope" for further file opens).
But, once that happens, the ImageCacheFile::mark_broken is called, which clears m_subimages. This invalidates the spec reference that the texture sampling function has locally.
Here's the problematic place:
TextureSystemImpl::texturedoestexturefile = verify_texturefile(fine), and thenconst ImageSpec& spec(texturefile->spec(options.subimage, 0))-- note that this is a reference- Later on, for an UDIM texture, the sampling callstack can end up being:
TextureSystemImpl::sample_bilinear ImageCacheImpl::find_tile ImageCacheImpl::find_tile_main_cache ImageCacheImpl::add_tile_to_cache # needs to read a different udim tile file! ImageCacheTile::read ImageCacheFile::read_tile ImageCacheFile::open # if this fails for whatever reason (my case: too many open files), ImageCacheFile::mark_broken # this invalidates the ImageSpec fetched above - Now, right before the filtering lookup if
fill_gray_channelsis called, this will readspecthat points to free'd memory.
OpenImageIO version and dependencies
2.5.11.0, but looking at file history of latest 3.0.0 the problem seems to exist there too.
To Reproduce
Reproducing is a bit involved since it needs ImageCacheFile::open to be failing. Whether that is due to too many open files (my case), or network/disk connectivity, etc. And it needs to be failing whereas the parent file check earlier in the texture function succeeds; which I think can only happen with UDIM textures.
I could "easily" reproduce this by using the Animal Logic ALab 2.2 data set, which is all UDIM exr files, on Windows MSVC with default open file limit of 100 (OIIO starts to use up to 500 open files, at which point this blows up). Setting max_open_files_strict makes this problem go away.
Evidence
I think the callstack and code flow outline above should point out the possible issue. Probably could be fixed by changing fill_gray_channels to not use the reference of the ImageSpec, but rather directly get the int nchannels and int alpha_channel, and the calling code reading those right after it gets the spec reference, so that they are not invalidated.
- 主要语言
- C++
- 星标
- 2.4k
- 派生
- 727
- 平均合并
- 4 天 8 小时
- 30 天内合并 PR
- 67
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
AcademySoftwareFoundation/OpenImageIO 的其他 Issue
-
bug: Python ImageBuf.get_pixels(oiio.UNKNOWN) returns None silently or segfaults可能重新可做 @stevwya77 于 10 天前认领,目前没有进行中的 PR。 未关闭bug good first issue python
难度 3/5 1-2 天 新手友好度 68/100
AcademySoftwareFoundation/OpenImageIO#5698 · 3 条评论 ·
维护者通常 3 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
AcademySoftwareFoundation/OpenImageIO#5619 · 2 条评论 ·
维护者通常 3 天内回复
-
难度 5/5 一周以上 新手友好度 10/100
AcademySoftwareFoundation/OpenImageIO#5570 ·
维护者通常 3 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
AcademySoftwareFoundation/OpenImageIO#5558 ·
维护者通常 3 天内回复
-
define which color metadata OpenImageIO trusts, and when it resolves it可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 5/5 一周以上 新手友好度 20/100
AcademySoftwareFoundation/OpenImageIO#5516 ·
维护者通常 3 天内回复
查看 AcademySoftwareFoundation/OpenImageIO 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
component: tabs platform: macOS
难度 2/5 1-3 小时 新手友好度 72/100
zen-browser/desktop#16860 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
windirstat/windirstat#776 ·
维护者通常 2 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
godotengine/godot#125913 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 90/100