On 2025-06-07 03:52, Pip Cet wrote: > I'm hitting this bug with some regularity (and working around it by > force-returning from Finsert_file_contents in gdb) on the MPS branch. > It's not a problem, but I am occasionally reminded it's still there :-) I finally shook loose some free time to work on this, and installed a series of patches into master which I hope fix the bug. Please give the patches a try. For convenience in review, I'm attaching a single diff combining all the patches, or you can look in the Git repository if you prefer to see each of the two dozen or so patches individually. The fix for Bug#77315 itself is quite simple: just remove the overlap checks. Overlap is impossible and the checks have bugs which can crash Emacs. (At least, overlap is impossible if you assume the other patches I installed....) The other patches are ones that I discovered while reading the code in the neighborhood. I was working along the lines that Eli hinted at when he wrote "insert-file-contents needs to be completely rewritten to handle such situations". The basic idea is to not trust st_size and to assume that file contents and size can change at any moment. My goodness, what a mess insert-file-contents was and remains! I hope I fixed more bugs than I introduced....