Commit 87a0d87
fix: use shared_ptr for resolution callback lifetime in WasmModuleCompilation
Replace RustCallable class with shared_ptr<void> to properly handle
std::function copy semantics in V8's Finish method. The previous approach
caused heap-use-after-free because V8 copies the std::function internally,
and the RustCallable copy/destroy semantics couldn't coordinate ownership
of the raw pointer across copies.
Now the Rust closure data is reference-counted through shared_ptr copies,
and the Rust side uses Option<Box<dyn FnOnce>> so the trampoline can
.take() the closure without freeing the outer allocation.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent e3654e8 commit 87a0d87
2 files changed
+36
-61
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3809 | 3809 | | |
3810 | 3810 | | |
3811 | 3811 | | |
3812 | | - | |
3813 | | - | |
3814 | | - | |
3815 | | - | |
3816 | | - | |
3817 | | - | |
3818 | | - | |
3819 | | - | |
3820 | | - | |
3821 | | - | |
3822 | | - | |
3823 | | - | |
3824 | | - | |
3825 | | - | |
3826 | | - | |
3827 | | - | |
3828 | | - | |
3829 | | - | |
3830 | | - | |
3831 | | - | |
3832 | | - | |
3833 | | - | |
3834 | | - | |
3835 | | - | |
3836 | | - | |
3837 | | - | |
3838 | | - | |
3839 | | - | |
3840 | | - | |
3841 | | - | |
3842 | | - | |
3843 | | - | |
3844 | | - | |
3845 | | - | |
3846 | | - | |
3847 | | - | |
3848 | | - | |
3849 | | - | |
3850 | | - | |
3851 | | - | |
3852 | | - | |
3853 | | - | |
3854 | | - | |
3855 | | - | |
3856 | | - | |
3857 | | - | |
3858 | | - | |
3859 | | - | |
3860 | | - | |
3861 | | - | |
3862 | | - | |
3863 | | - | |
3864 | | - | |
3865 | | - | |
3866 | 3812 | | |
3867 | 3813 | | |
3868 | 3814 | | |
3869 | 3815 | | |
3870 | 3816 | | |
3871 | 3817 | | |
| 3818 | + | |
| 3819 | + | |
| 3820 | + | |
| 3821 | + | |
| 3822 | + | |
| 3823 | + | |
3872 | 3824 | | |
3873 | 3825 | | |
3874 | | - | |
| 3826 | + | |
| 3827 | + | |
| 3828 | + | |
| 3829 | + | |
| 3830 | + | |
| 3831 | + | |
| 3832 | + | |
| 3833 | + | |
| 3834 | + | |
| 3835 | + | |
| 3836 | + | |
3875 | 3837 | | |
3876 | 3838 | | |
3877 | 3839 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
352 | 352 | | |
353 | 353 | | |
354 | 354 | | |
355 | | - | |
356 | | - | |
357 | | - | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
358 | 362 | | |
359 | 363 | | |
360 | 364 | | |
| |||
441 | 445 | | |
442 | 446 | | |
443 | 447 | | |
444 | | - | |
445 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
446 | 456 | | |
447 | 457 | | |
448 | 458 | | |
449 | 459 | | |
450 | 460 | | |
451 | 461 | | |
452 | | - | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
453 | 466 | | |
454 | 467 | | |
455 | 468 | | |
| |||
0 commit comments