Ludovic Courtès schreef op ma 04-07-2022 om 12:09 [+0200]: > But we could provide special semantics: the bytevector would become > zero-length (possible, but weird, as Maxime points out), or it would > be turned into a /dev/zero mapping (weird as well). > > Thoughts?
The former is weird and can currently cause out-of-bound reads/writes (see the TOCTTOU issue I pointed out). It also would also prevent optimisations (for things like (bytevector-ref bv 9999) (bytevector-ref bv 1), to eliminate some range checks). The latter is weird too, but it's easy to reason about -- the compiler can assume the bytevector length is fixed, so no TOCTTOU issue and possibility of optimisations, user code also doesn't have to worry about changing lengths, no bad interactions with the bytevector->pointer + pointer->bytevector trick to reduce the range of a bytevector ... (except potential GC issues, to which I haven't yet received a response to test for them or resolve them or document limitations). As such, I would recommend the latter. Though if we go for the former, we might as well implement a bytevector-free! (why is there a munmap but not a bytevector-free!). Greetings, Maxime.