This might happen when the rewrite rules are flushed. The function insert_with_markers()
is using fopen()
, but not flock()
, so when two pieces of code are calling flush_rewrite_rules()
almost at the same time, the second process can write to that file before the first one has closed it.
Check your plugins and your theme for flush_rewrite_rules()
, especially those registering custom post types or taxonomies. Some poorly written plugins are calling this on every page load. Disable that plugin.