Skip to content
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

Cannot open package from in-memory buffer #13

Open
heaths opened this issue Dec 15, 2022 · 1 comment
Open

Cannot open package from in-memory buffer #13

heaths opened this issue Dec 15, 2022 · 1 comment

Comments

@heaths
Copy link

heaths commented Dec 15, 2022

I'm using a Cursor to read from an in-memory buffer using Package::open, but found this will err in WASM:

$core::option::expect_failed::ha758e0d1c5165b94 | @ | 50b8976……odule.wasm:0x13208b
$<std::time::SystemTime as core::ops::arith::Sub<core::time::Duration>>::sub::h47beefa3c5880621 | @ | 50b8976……odule.wasm:0x10eb9f
$msi::internal::time::filetime_epoch::h319c0984523cb136 | @ | 50b8976….module.wasm:0xf287e
$msi::internal::time::system_time_from_filetime::hb7b59f8afe76e03c | @ | 50b8976….module.wasm:0xbada6
$msi::internal::propset::PropertyValue::read::h8911128289f30e53 | @ | 50b8976….module.wasm:0x3783e
$msi::internal::propset::PropertySet::read::h221599500522a80f | @ | 50b8976….module.wasm:0x2541b
$msi::internal::summary::SummaryInfo::read::hff04ecde0b584c9d | @ | 50b8976….module.wasm:0x4fce8
$msi::internal::package::Package<F>::open::h20cfea195083e72b

While the source of the error is no doubt the constraints of the environment under which the code is running, it would be nice if certain errors might be skipped. There is no date-time that must be read from a \005SummaryInformation stream.

To note, this only fails in WASM I've found. I have separated functions to test locally like so:

#[wasm_bindgen(js_name = "getProductInfo")]
pub fn get_product_info(data: &[u8]) -> Result<ProductInfo, JsValue> {
    let cursor = Cursor::new(data);

    console_log!("opening package from {} bytes", data.len());
    let info = read_product_info(cursor).unwrap_throw();

    Ok(info)
}

pub fn read_product_info<R>(data: R) -> Result<ProductInfo, Box<dyn Error + Send + Sync>>
where
    R: Read + Seek,
{
    let mut package = Package::open(data)?;
    // ...
}

Calling read_product_info locally works fine. This is just for context, though; again, I realize the source of the underlying problem isn't here: I'm just questioning whether failing to read some data should be strictly fatal.

@heaths
Copy link
Author

heaths commented Dec 15, 2022

FWIW, the underlying bug is in the std library for WASM: rust-lang/rust#105762

heaths added a commit to heaths/msi-wasm that referenced this issue Dec 16, 2022
heaths added a commit to heaths/rust-msi that referenced this issue Dec 16, 2022
Temporarily works around mdsteele#13 in a vendored directory to finish POC.

Long-term if the upstream issue in rust-lang/rust isn't fixed, it may be worth copying the SystemTime definition for Windows.
heaths added a commit to heaths/rust-msi that referenced this issue Aug 10, 2024
Temporarily works around mdsteele#13 in a vendored directory to finish POC.

Long-term if the upstream issue in rust-lang/rust isn't fixed, it may be worth copying the SystemTime definition for Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant