Commit a555dc7
authored
fix(go): prevent GC finalizer on borrowed resource handles (#1539)
* chore: add dev-dependencies for integration tests
Add wit-bindgen-core, wit-bindgen-rust, wit-bindgen-go, and wit-parser
as workspace dev-dependencies to support integration test files.
* fix(go): prevent GC finalizer on borrowed resource handles
FromBorrowHandle for imported resources was incorrectly delegating to
FromOwnHandle, which registers a GC finalizer via runtime.AddCleanup.
This violates the Component Model specification: borrowed handles are
not owned by the callee, so the callee must not drop them. When Go's
garbage collector ran, it would drop borrowed handles through the
finalizer, corrupting the host's resource table.
Fix FromBorrowHandle to create a handle object directly without
registering a GC finalizer, preserving the correct ownership semantics.1 parent 434322d commit a555dc7
3 files changed
+43
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2589 | 2589 | | |
2590 | 2590 | | |
2591 | 2591 | | |
2592 | | - | |
| 2592 | + | |
| 2593 | + | |
2593 | 2594 | | |
2594 | 2595 | | |
2595 | 2596 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
0 commit comments