Questions tagged [memory-safety]
For questions about memory safety features in programming languages, to prevent misuse of memory and related errors.
12 questions
8
votes
2
answers
755
views
Analysis of methods to ensure memory safety
Overview
Ensuring memory safety is a core facet of modern programming language design. Memory safety can be guaranteed in many different ways.
For the purposes of this question, I am defining memory ...
16
votes
3
answers
6k
views
What programming languages implement memory safety?
One of the most known ones is Rust, but what others implement this?
7
votes
0
answers
344
views
What is the history of using dependent types to avoid array bound checks
Context
For memory safe languages to be fast, array bounds should be checked during compilation. Some language like Java, Rust, Swift, and others eliminate array bounds checks when possible, but the ...
8
votes
5
answers
4k
views
What is the explicit list of the situations that require RAII?
RAII, the acronym for "resource acquisition is initialization", is a crucial paradigm of C++ that is meant to prevent the following things:
Forgetting to free a dynamic storage
Forgetting ...
8
votes
4
answers
5k
views
Does using Rust eliminate the need to implement garbage collection in a language?
I am new to language development. I am aware of Rust's ownership model that builds programs in a way that does not need garbage collection.
So if I am to build a new programming language using safe ...
23
votes
10
answers
6k
views
Why would accessing uninitialized memory necessarily be undefined behavior?
In C, accessing any indeterminate/uninitialized memory is undefined behavior, period. Even in the case that the type in question is guaranteed to have no trap representations, such as ...
3
votes
1
answer
333
views
Memory layout from a native class
I think there are languages where most of the standard library is written in themselves, however with most things marked as native or ...
0
votes
1
answer
948
views
Creating a high level language that transpiles to rust
I really like what Rust brings to the table, but I find it very difficult to work with if I am not really working on apps that require absolute speed and the lower-levelness e.g. specifying int sizes, ...
11
votes
4
answers
976
views
Can a language allow raw pointer dereferencing while preserving memory safety?
In Rust, creating a raw pointer is allowed in safe code (i.e. outside of unsafe blocks), but then dereferencing it is unsafe:
...
6
votes
5
answers
886
views
Approaches for implementing weak references
How can weak references (weakrefs) be implemented, and how do the different approaches compare?
The most important considerations for implementing weakrefs are:
Safety ─ a weakref shouldn't allow ...
15
votes
2
answers
761
views
Could ownership be inferred?
Rust famously has the concept of ownership vs. borrowing as part of its type system. This allows some level of automatic memory management ─ that is, heap allocations are freed when their owner goes ...
14
votes
4
answers
2k
views
Is it possible to extend C to have the Rust concept of ownership for memory safety?
Rust has a number of memory safety features. Is it possible to extend or enhance C or C++ to also provide similar memory safety features instead of using workarounds such as the Valgrind tool suite?