-
Notifications
You must be signed in to change notification settings - Fork 825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: UnwindRegistry
owns the eh_frame
s
#1583
Conversation
`UnwindRegistry` registers `eh_frame` from a slice. This slice is a pointer owned by `SerializableModule`, which is held by `Artifact`. If the artifact is dropped _before_ the `UnwindRegistry`, then we have a dangling pointer, and it can crash. Actually, it crashes, see wasmerio#1581 as our first attempt to fix this problem. So instead of `UnwindRegistry` to register a pointer to a data it doesn't own, this patch updates `UnwindRegistry` to register a pointer to data that it owns. `UnwindRegistry` now receives an `eh_frame` of kind `Vec<u8>` instead of `&[u8]`. The bytes are copied. In addition, this patch creates an `UnwindRegistryExt` trait, so that it brings consistency amongst all `UnwindRegistry` implementation (`systemv`, `windows_x64` and `dummy`). This is for an internal usage only.
@@ -1,3 +1,20 @@ | |||
use wasmer_compiler::CompiledFunctionUnwindInfo; | |||
|
|||
pub trait UnwindRegistryExt { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced we need a trait, only one implementation would be needed at runtime (or compiled in the code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use impl Trait
for this if the concern is correctness and efficiency. If the concern is over abstraction though, then that doesn't fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The concern is correctness. It declares an interface that all unwind registry implementations must fulfill.
bors try |
I think there's a more fundamental issue about the pub(crate) fn allocate_custom_sections(
&mut self,
custom_sections: &PrimaryMap<SectionIndex, CustomSection>,
) -> Result<PrimaryMap<SectionIndex, *const u8>, CompileError> With this signature, it's hands-off as soon as the allocation is done. There's nothing tying the It might be possible to do it differently tho:
|
tryTimed out. |
I think @sebpuetz is correct. I didn't realize that ModuleInfo no longer owned the custom section data anymore but that seems to be a fundamental issue. It's likely non-trivial to make this work without that, so I think the best course of action is to make sure ModuleInfo can stand on its own. |
Outdated by #1628. |
UnwindRegistry
registerseh_frame
from a slice. This slice is apointer owned by
SerializableModule
, which is held byArtifact
. Ifthe artifact is dropped before the
UnwindRegistry
, then we have adangling pointer, and it can crash. Actually, it crashes, see
#1581 as our first attempt to
fix this problem.
So instead of
UnwindRegistry
to register a pointer to a data itdoesn't own, this patch updates
UnwindRegistry
to register a pointerto data that it owns.
UnwindRegistry
now receives aneh_frame
ofkind
Vec<u8>
instead of&[u8]
. The bytes are copied.In addition, this patch creates an
UnwindRegistryExt
trait, so thatit brings consistency amongst all
UnwindRegistry
implementation(
systemv
,windows_x64
anddummy
). This is for an internal usageonly.
Note that this PR fixes the problem I've with
python-ext-wasm
, but Iwould be very surprised if it doesn't break existing tests.
cf #1568
cc @syrusakbary @sebpuetz