-
Notifications
You must be signed in to change notification settings - Fork 8
Note on resources, and undefined behavior inside the cycles (long term planning) #5
Comments
Interesting. Yeah, I thought about that, in fact, that was the whole point of the cycles, or at least, what initially made me create them, but after creating them I saw its potential utility was bigger than just avoiding undefined behavior. I agree with you in the best solution, not the most easy to implement, but still the best one. As long as this is still something we are concerned about, we should have it document it, as you said. I'll create a separate branch later, so we can start working on this. Feel free to fork it and start working on the solution |
Bug because (can) cause undefined behavior, documentation because is not warned in the docs, enhancement because the solution will prevent undefined behavior and warn the user. |
If it's documented, it's not really undefined anyways. |
in fact no. it's undefined behavior because you cant predict what will happen, you just know that an error will happen |
It is undefined behavior to attempt to use and modify a resource by more than one process/thread at the same time, it's also called a data race. Doesn't matter wether you know it's there or not, it's still going to happen and produce undefined results when executed. Rust prevents data races with memory but not with files in the disk that can only be affected with syscalls. |
I feel like refusing to run would be excessive, since then the user has no way to do two moves of different files simultaneously that don't conflict between themselves, for example. I propose a new idea: warn and give a prompt (to continue) so the user can revise it. We could have a flag |
yes I was considering the idea of the flags |
With the new parser this should be easier to implement. I'll start working on it |
Look at the below snippet:
This snippet triggers undefined behavior, as it's using a resource potentially destructively (
delete
will certainly do,my-useful-check
might do). You don't know which one will error out, ifdelete
orshell
. It could be thatshell
finds the file whiledelete
is still working on it, and you never know what will happen next.This issue is meant to open a debate. How shall we mitigate this issue? I've thought of three options, let me know if you have any more:
Final note: I don't think we should start working on this immediately, but instead come up with different ideas or expand one of them as the project matures.
The text was updated successfully, but these errors were encountered: