mirror of
https://github.com/cmusphinx/sphinxtrain.git
synced 2026-11-18 21:13:33 +00:00
sync_runtime() regenerates etc/sphinx_train.resolved.json from every script that loads SphinxTrain::Config, so the parallel comp_feat shards can enter write_file() concurrently. It opened the target with ">", truncating it in place and bumping its mtime; a sibling shard then judged the file fresh, read it while still empty, and died "malformed JSON string ... (end of string)" at BEGIN -- surfacing as "Parallel job failed with exit code 255" with no shard log. This is the actual cause of the flaky train-g2p-lda-vtln / train-parallel failures. Write a per-process temp file and rename() it over the target (atomic on POSIX) so a concurrent reader always sees a complete file.