but then you have to manage cached/unchached yourself.
I do not know anything about that.
I'm sure we've discussed it before, I'll leave it to you to dig up the threads, umalloc vs malloc might help find it.
There have also been bugs both in the ptpcam and chdk sides that caused some data to be corrupted
Yes, but the camera does not get as far as opening the file to send the data.
But the file name is also sent as a data transfer.
Recording / displaying the file name on the camera might help prove or disprove this. I know you said you verified the name was OK, but I'm not clear if that was on the cam.
If I repeat the command after getting the error, the camera crashes.
If an expected data phase is not performed, it will generally hang PTP at least.
Out of memory would also be plausible, if you can't allocate 32k for a file handle, it is very likely something else on the camera will try to malloc and fail soon.
A romlog would help distinguish between these.
Which camera(s) are you testing with?