Skip to content

Commit 62865b0

Browse files
committed
scratch: make wrappable finalizable (match ClosureTracer)
1 parent 688c96b commit 62865b0

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

cppgc-repro/binding.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Minimal reproduction: cppgc::MakeGarbageCollected crashes inside an addon on
22
// arm64 macOS. Build with node-gyp; call `make()` from JS.
33
#include <cstdio>
4+
#include <mutex>
5+
#include <vector>
46
#include <node.h>
57
#include <v8.h>
68

@@ -9,9 +11,15 @@
911
#include "cppgc/visitor.h"
1012
#include "v8-cppgc.h"
1113

14+
// Match node-gtk's ClosureTracer: non-trivial (mutex + vector + destructor), so
15+
// cppgc registers a finalizer for it. The trivial version did NOT crash.
1216
class Wrappable final : public cppgc::GarbageCollected<Wrappable> {
1317
public:
1418
void Trace(cppgc::Visitor*) const {}
19+
~Wrappable() { v.clear(); }
20+
private:
21+
mutable std::mutex m;
22+
std::vector<void*> v;
1523
};
1624

1725
static void Make(const v8::FunctionCallbackInfo<v8::Value>& info) {

0 commit comments

Comments
 (0)