kurtlawrence / papyrus

(Rust) repl
MIT License
439 stars 14 forks source link

Keep loaded libraries in memory #44

Closed kurtlawrence closed 4 years ago

kurtlawrence commented 4 years ago

There is a very specific use case which can result in segfaults. The implementer must send through an object such as a channel that can be sent some actionable thing. Once the papyrus code finishes, if this code is called it will be called on invalid memory (as the library has been dropped at this point).

The solution may be to store loaded libraries, and give the ability to clear the cache at user defined points. Storing would not be the preferred option so would have to be opted into.

Todo:

kurtlawrence commented 4 years ago

Renaming was done previously to solve a different issue, the reasoning is kept here.

[Renaming] Has to be done to make linux builds work see:

Basically the api function dlopen will keep loaded libraries in memory to avoid continuously allocating memory. It only does not release the library when threadlocal data is hanging around, and it seems println!() is something that does this. Hence to avoid not having the library not updated with a new new() call, a different lib name is passed to the function. This is very annoying as it has needless fs interactions and a growing fs footprint but> what can you do ¯_(ツ)