You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When referring to a string literal, the compiler inserts an atomic increment automatically. This ensures that when we're done with the string literal, the ref count is reduced to what it was before, and thus the memory isn't dropped. This means that the minimum ref count when we start using the string is always 2.
However, it's technically possible to increment the same string $2^{32} - 1$ times such that the counter overflows to 1. The next decrement then observes the new value to be zero, and proceeds to drop the string. The next decrement (or any use of the string for that matter) then operates on invalid memory.
Although it's unlikely to run into such many increments in reality, it's technically possible and thus technically unsound. Since at compile time we can't tell the difference between a compile-time string and a runtime string (as they're meant to be interchangeable), this would require additional runtime support (e.g. an extra flag in the object header). This however could incur an additional cost, while in reality we might never need it. As such, I'm not sure yet what to do here (if anything).
Operating system
Fedora
Inko version
main
The text was updated successfully, but these errors were encountered:
Please describe the bug
When referring to a string literal, the compiler inserts an atomic increment automatically. This ensures that when we're done with the string literal, the ref count is reduced to what it was before, and thus the memory isn't dropped. This means that the minimum ref count when we start using the string is always 2.
However, it's technically possible to increment the same string$2^{32} - 1$ times such that the counter overflows to 1. The next decrement then observes the new value to be zero, and proceeds to drop the string. The next decrement (or any use of the string for that matter) then operates on invalid memory.
Although it's unlikely to run into such many increments in reality, it's technically possible and thus technically unsound. Since at compile time we can't tell the difference between a compile-time string and a runtime string (as they're meant to be interchangeable), this would require additional runtime support (e.g. an extra flag in the object header). This however could incur an additional cost, while in reality we might never need it. As such, I'm not sure yet what to do here (if anything).
Operating system
Fedora
Inko version
main
The text was updated successfully, but these errors were encountered: