SerenityOS / serenity

The Serenity Operating System 🐞
https://serenityos.org
BSD 2-Clause "Simplified" License
30.35k stars 3.17k forks source link

LibJSGCVerifier: Complain about malloc-backed containers of GC pointers on the stack #23852

Open awesomekling opened 5 months ago

awesomekling commented 5 months ago

Putting e.g a Vector<JS::GCPtr<JS::Object>> on the stack is not safe, as Vector is backed by malloc memory.

Consequently, it's also inappropriate as a function return type.

We should complain about this, so the user can switch to using MarkedVector<JS::GCPtr<JS::Object>> or at least Vector<JS::Handle<JS::Object>>.

We need to do this for all malloc-backed containers, but for simplicity let's say: Vector, HashMap, HashTable, and Queue.

Funding

Fund with Polar

TomasBorquez commented 3 months ago

Hey I would like to take this but i'm not sure what you mean with "complain", do you mean a compile-time error that blocks the build if such patterns are detected, or a compile time warning that notifies the developer of the unsafe usage without stopping the build? I am considering using static_assert for errors or a custom type trait with a [[deprecated]] attribute for warnings