目录
Andreas Gampe

Fix JSONL row loss in sb-to-lines segment merge

Summary: The source-block-to-lines mapping is written by collect_source_block_to_lines_mapping via per-segment worker threads that each write a temp file, which a merger thread concatenates in order into the final JSONL. Two defects caused the merged output to silently drop the majority of emitted rows (measured at ~61% loss: the collector emitted 3,614,998 rows but only 1,417,120 reached the file).

  1. Flush race: each worker signaled completion (finished_segments.insert(idx) + notify_all()) while its std::ofstream was still open — the stream is only flushed and closed when the lambda scope exits, after the signal. The merger could therefore read and std::filesystem::remove() a not-yet-flushed segment file, and the worker’s final flush would then land on an unlinked inode. Fixed by calling ofs.close() before signaling completion.

  2. Failbit poisoning: the merge copy ofs << ifs.rdbuf() sets the output stream’s failbit whenever zero characters are inserted (an empty segment file, i.e. a segment whose methods produced no rows). Once the failbit is set, every subsequent ofs << ifs.rdbuf() is a silent no-op, dropping all later segments. Fixed by only performing the copy when the segment file is non-empty (ifs && ifs.peek() != eof); the file is still removed either way.

With both fixes the JSONL file now contains every emitted row.

Reviewed By: danjin250

Differential Revision: D113465381

fbshipit-source-id: 7f047d6557bc59ef5fb8e2285ffa0c76dca499fe

2天前10095次提交

ReDex: An Android Bytecode Optimizer

ReDex is an Android bytecode (dex) optimizer originally developed at Facebook. It provides a framework for reading, writing, and analyzing .dex files, and a set of optimization passes that use this framework to improve the bytecode. An APK optimized by ReDex should be smaller and faster than its source.

Go to https://fbredex.com for full documentation.

Contributions

See CONTRIBUTING.md to understand how to contribute to this project.

License

The ReDex repository is available under the MIT License.

邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

版权所有:中国计算机学会技术支持:开源发展技术委员会
京ICP备13000930号-9 京公网安备 11010802047560号