dtolnay / typetag

Serde serializable and deserializable trait objects
Apache License 2.0
1.19k stars 38 forks source link

`web_event` example fails #17

Closed nlewycky closed 2 years ago

nlewycky commented 5 years ago

I tried the web_event example and it doesn't work for me at current head post 0.1.4 (5d8ff37da6958e1096c1ee08f842f048762bf314).

$ cargo run --example web_event
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `target/debug/examples/web_event`
PageLoad json: {"type":"PageLoad"}
Error: Error("unknown variant `PageLoad`, there are no variants", line: 1, column: 18)

I've tried both +stable and +nightly and I get the same error.

This is affecting us on https://github.com/wasmerio/wasmer where we serialize WebAssembly virtual filesystem state. So far I'm the only one affected, it passes on my coworker's computer and on our CI, but the new test was only added yesterday.

nlewycky commented 5 years ago

I should have checked the tests before filing:

$ cargo test
   Compiling typetag v0.1.4 (/home/nicholas/typetag)
    Finished dev [unoptimized + debuginfo] target(s) in 12.16s
     Running target/debug/deps/typetag-1f07741bc2275101

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running target/debug/deps/test-1e2806ad0ac9bf05

running 11 tests
test adjacently_tagged::test_json_serialize ... ok
test externally_tagged::test_json_serialize ... ok
test externally_tagged::test_json_deserialize ... FAILED
test adjacently_tagged::test_bincode_round_trip ... FAILED
test adjacently_tagged::test_json_deserialize ... FAILED
test internally_tagged::test_json_serialize ... ok
test marker_traits::deserialize ... ok
test externally_tagged::test_bincode_round_trip ... FAILED
test marker_traits::test_serialize ... ok
test internally_tagged::test_json_deserialize ... FAILED
test internally_tagged::test_bincode_round_trip ... FAILED

failures:

---- externally_tagged::test_json_deserialize stdout ----
thread 'externally_tagged::test_json_deserialize' panicked at 'called `Result::unwrap()` on an `Err` value: Error("unknown variant `B`, there are no variants", line: 1, column: 4)', src/libcore/result.rs:1165:5

---- adjacently_tagged::test_bincode_round_trip stdout ----
thread 'adjacently_tagged::test_bincode_round_trip' panicked at 'called `Result::unwrap()` on an `Err` value: Custom("unknown variant `A`, there are no variants")', src/libcore/result.rs:1165:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

---- adjacently_tagged::test_json_deserialize stdout ----
thread 'adjacently_tagged::test_json_deserialize' panicked at 'called `Result::unwrap()` on an `Err` value: Error("unknown variant `B`, there are no variants", line: 1, column: 11)', src/libcore/result.rs:1165:5

---- externally_tagged::test_bincode_round_trip stdout ----
thread 'externally_tagged::test_bincode_round_trip' panicked at 'called `Result::unwrap()` on an `Err` value: Custom("unknown variant `A`, there are no variants")', src/libcore/result.rs:1165:5

---- internally_tagged::test_json_deserialize stdout ----
thread 'internally_tagged::test_json_deserialize' panicked at 'called `Result::unwrap()` on an `Err` value: Error("unknown variant `B`, there are no variants", line: 1, column: 11)', src/libcore/result.rs:1165:5

---- internally_tagged::test_bincode_round_trip stdout ----
thread 'internally_tagged::test_bincode_round_trip' panicked at 'called `Result::unwrap()` on an `Err` value: Custom("unknown variant `A`, there are no variants")', src/libcore/result.rs:1165:5

failures:
    adjacently_tagged::test_bincode_round_trip
    adjacently_tagged::test_json_deserialize
    externally_tagged::test_bincode_round_trip
    externally_tagged::test_json_deserialize
    internally_tagged::test_bincode_round_trip
    internally_tagged::test_json_deserialize

test result: FAILED. 5 passed; 6 failed; 0 ignored; 0 measured; 0 filtered out

error: test failed, to rerun pass '--test test'

This is on Debian unstable on x86-64 with rust installed via rustup. If there's anything I can do to help you debug, please let me know.

dtolnay commented 5 years ago

This is likely due to using a different linker, https://github.com/mmastrac/rust-ctor/issues/17. The ctor crate needs to be updated to support LLD.

nlewycky commented 5 years ago

Yep, I am using LLD. I was expecting it to only cause linker failures, not runtime problems. Thanks for the very quick reply!

AgarwalPragy commented 4 years ago

This still seems to be an issue when compiling to webassembly. Any way to work around it?

dtolnay commented 4 years ago

WebAssembly requires https://github.com/mmastrac/rust-ctor/issues/14.