3 ms·
If you put the global allocator on this there is a huge load of other issues you can have. Like needing to allocate a fixed amount of memory for your whole pro
by dathinab 3y ago
If you put the global allocator on this there is a huge load of other issues you can have.
Like needing to allocate a fixed amount of memory for your whole program upfront or juggling multiple fds.
Or that there is some state you can not carry over even with that and if you try you can easily run into soundness issues.
Or that the state saved might be "in between" operations in a very unexpected way and in turn unsound.
etc.
- gpm 3y ago> Like needing to allocate a fixed amount of memory for your whole program upfront Can I not do the normal virtual memory thing and allocate far more memory than I actually have hardware for? > Or that there is some state you can not carry over even with that and if you try you can easily run into soundness issues. I mean, fair... you're going to have to be careful what you save either way but making saving things the default does seem like more of a footgun. > Or that the state saved might be "in between" operations in a very unexpected way and in turn unsound. This applies even if you only use it for some structs? This whole mechanism seems like it would only be sound if it was only used after clean exits.
- dathinab 3y ago> sound if it was only used after clean exits. yes, except maybe if a Drop constructor is run unexpectedly on the exit or similar generally I think using it with anything which has pointers and/or runs Drop in it is brittle and prone to bugs in turn most things which do not have pointers should be fine with a clean exit and anything which only consists of memory where any bit combination is always valid should always be sound even on a abort (e.g. a `[u8]` allocated directly in that memory region or a `[T]` where `T` only has primitive non-allocating types)
- throwaway09223 3y agoThe common place to use something like this would be to mmap an existing external data structure. There are a number of existing mmap-able 0copy k/v library/db formats that fit the bill here.