Blank row in mpc.gencost reads past the start of the string
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
从 GridKit/Model/PowerFlow/MatpowerParser.hpp 中的 readMatPowerGenCostRow 开始,使用包含空行的 mpc.gencost 用例,通过 readMatPower 重现该问题。验证空行不再发生越界读取,而是改为引发 parser 的语法错误;重新运行 clang++ AddressSanitizer 构建,以确认下溢已消失。
由索引模型根据 Issue 内容生成。
描述
Following up on #580, which @pelesh closed asking for an issue with a reproducer and a suggested solution.
readMatPowerGenCostRow in GridKit/Model/PowerFlow/MatpowerParser.hpp checks the last character after trimming:
rtrim(row);
if (row[row.size() - 1] != ';')
A blank line inside mpc.gencost leaves row empty, so row.size() - 1 wraps around and the read goes out of bounds.
Reproducer, driving GridKit::readMatPower with a small case file whose mpc.gencost block starts with an empty line:
mpc.gencost = [
2 0 0 3 0.01 40 0;
];
Built with clang++ -std=c++17 -fsanitize=address -g:
==36380==ERROR: AddressSanitizer: stack-buffer-underflow
#0 readMatPowerGenCostRow<double, int> MatpowerParser.hpp:156
#0 readMatPower<int, double, 1028ul> MatpowerParser.hpp:211
The bus, gen and branch row readers take the same line without trouble, since they only read through operator>>, so this is specific to the gencost reader.
Suggested solution: treat an empty row the way a row with the wrong terminator is treated, so the reader raises the parser's own syntax error rather than indexing the string. Something as small as checking for an empty string before looking at the last character is enough; I have that change and the reproducer ready if you would like a PR against it.
- 主要语言
- C++
- 星标
- 27
- 派生
- 11
- 平均合并
- 2 天 21 小时
- 30 天内合并 PR
- 15
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
ORNL/GridKit 的其他 Issue
-
Companion OPF models for PD initialization constraints可能已有人在做 @lukelowry 于 3 天前认领。 未关闭IVP question
维护者通常 1 天内回复
-
Extract CommonMath functions可能已有人在做 @amandeep25100-a11y 于 6 天前认领。 未关闭cleanup
难度 4/5 3-5 天 新手友好度 54/100
维护者通常 1 天内回复
-
enhancement question
难度 5/5 一周以上 新手友好度 30/100
ORNL/GridKit#624 · 2 条评论 · 2 个 reaction ·
维护者通常 1 天内回复
-
Add support for hierarchical modeling to the JSON format case file specifications可能已有人在做 @abirchfield 于 33 天前认领。 未关闭documentation enhancement new case question
ORNL/GridKit#619 · 8 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
Separate Rosenbrock integrator interface to GridKit from the integrator implementation.可能重新可做 @alexander-novo 于 33 天前认领,目前没有进行中的 PR。 未关闭enhancement new solver
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 86/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
-
难度 2/5 1-3 小时 新手友好度 65/100
grizzlypeak3d/DJV#962 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复