fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.12k stars 283 forks source link

[Bug] frb_codegen memory sanitizer error #776

Closed jwinarske closed 1 year ago

jwinarske commented 1 year ago

Describe the bug

RUSTFLAGS="-Z sanitizer=memory" cargo run

  ==632210==WARNING: MemorySanitizer: use-of-uninitialized-value
      #0 0x55f541934d13 in core::option::Option$LT$T$GT$::is_some::h6504ac36d17313c0 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/core/src/option.rs:554:9
      #1 0x55f541939a96 in build_script_build::is_env_set::h8e7cbe63f4b7a2b6 /home/joel/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-2.5.0/build.rs:81:5
      #2 0x55f541938717 in build_script_build::enable_simd_optimizations::h925c3a3c32cf8eef /home/joel/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-2.5.0/build.rs:18:8
      #3 0x55f5419386e5 in build_script_build::main::h9eb6f0894224e0bd /home/joel/.cargo/registry/src/github.com-1ecc6299db9ec823/memchr-2.5.0/build.rs:4:5
      #4 0x55f541940c5c in core::ops::function::FnOnce::call_once::hb927535bb1e13e02 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/core/src/ops/function.rs:251:5
      #5 0x55f54193d9e2 in std::sys_common::backtrace::__rust_begin_short_backtrace::he72e235dbb51202a /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/sys_common/backtrace.rs:122:18
      #6 0x55f541934121 in std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h1660c9fd80123a4e /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/rt.rs:166:18
      #7 0x55f54195609a in core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::hcf0f452e35b42714 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/core/src/ops/function.rs:286:13
      #8 0x55f54195609a in std::panicking::try::do_call::h9076463b86fc98c2 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/panicking.rs:464:40
      #9 0x55f54195609a in std::panicking::try::h59a38c38fab81132 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/panicking.rs:428:19
      #10 0x55f54195609a in std::panic::catch_unwind::h024c7f29e5fae637 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/panic.rs:137:14
      #11 0x55f54195609a in std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::h1bc9c4aefbf9b583 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/rt.rs:148:48
      #12 0x55f54195609a in std::panicking::try::do_call::hf630db2c23823f3c /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/panicking.rs:464:40
      #13 0x55f54195609a in std::panicking::try::h5c6c892f05382366 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/panicking.rs:428:19
      #14 0x55f54195609a in std::panic::catch_unwind::h893ebad4c00d9e60 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/panic.rs:137:14
      #15 0x55f54195609a in std::rt::lang_start_internal::h2fa3ed5bcd048bb3 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/rt.rs:148:20
      #16 0x55f541933ff5 in std::rt::lang_start::h8e4bd8244ea16f8c /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/rt.rs:165:17
      #17 0x55f541939f89 in main (/b/flutter_rust_bridge/target/debug/build/memchr-359aa0212e42dbd4/build-script-build+0x82f89) (BuildId: ce6f23565ee85b7326f5af230312587aa2bf2271)
      #18 0x7f85c99d2b74 in __libc_start_main (/lib64/libc.so.6+0x27b74) (BuildId: 08df60634339b221bb854d4e10b7278cafde70c4)
      #19 0x55f5418c60dd in _start (/b/flutter_rust_bridge/target/debug/build/memchr-359aa0212e42dbd4/build-script-build+0xf0dd) (BuildId: ce6f23565ee85b7326f5af230312587aa2bf2271)

  SUMMARY: MemorySanitizer: use-of-uninitialized-value /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/core/src/option.rs:554:9 in core::option::Option$LT$T$GT$::is_some::h6504ac36d17313c0
  Exiting

Codegen logs with RUST_LOG=debug environment variable

NA

To Reproduce

RUSTFLAGS="-Z sanitizer=memory" cargo run

Expected behavior

free of failures

Generated binding code

No response

OS

Linux

Version of flutter_rust_bridge_codegen

master tip of tree

Flutter info

No response

Version of clang++

No response

Version of ffigen

No response

Additional context

No response

jwinarske commented 1 year ago

Also

Input

pushd frb_codegen
RUST_LOG=debug RUSTFLAGS="-Z sanitizer=memory" cargo run --target x86_64-unknown-linux-gnu --verbose --package flutter_rust_bridge_codegen --bin flutter_rust_bridge_codegen --features "chrono,uuid" --  --rust-input ../frb_example/pure_dart/rust/src/api.rs --dart-output ../frb_example/pure_dart/dart/lib/bridge_generated.dart --dart-decl-output ../frb_example/pure_dart/dart/lib/bridge_definitions.dart --dart-format-line-length 120 --wasm

Output Tail

==636679==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x5639015c107c in core::option::Option$LT$T$GT$::map::h38ad6799827d9dcd /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/core/src/option.rs:924:9
    #1 0x5639015436fa in _$LT$core..iter..adapters..map..Map$LT$I$C$F$GT$$u20$as$u20$core..iter..traits..iterator..Iterator$GT$::next::hbdf0d5bc577ecc93 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/core/src/iter/adapters/map.rs:103:9
    #2 0x56390110ba80 in _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$alloc..vec..spec_from_iter_nested..SpecFromIterNested$LT$T$C$I$GT$$GT$::from_iter::h0b89e2a67243509f /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/alloc/src/vec/spec_from_iter_nested.rs:26:32
    #3 0x563901192c31 in _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$alloc..vec..spec_from_iter..SpecFromIter$LT$T$C$I$GT$$GT$::from_iter::h79476d59834e12f1 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/alloc/src/vec/spec_from_iter.rs:33:9
    #4 0x5639011844ef in _$LT$alloc..vec..Vec$LT$T$GT$$u20$as$u20$core..iter..traits..collect..FromIterator$LT$T$GT$$GT$::from_iter::h4fc6ffd406061e5e /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/alloc/src/vec/mod.rs:2714:9
    #5 0x56390155fee1 in core::iter::traits::iterator::Iterator::collect::h01e826217c355cfa /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/core/src/iter/traits/iterator.rs:1836:9
    #6 0x563901453be7 in _$LT$clap_lex..RawArgs$u20$as$u20$core..convert..From$LT$I$GT$$GT$::from::h1b62d2edcb6806e7 /home/joel/.cargo/registry/src/github.com-1ecc6299db9ec823/clap_lex-0.2.4/src/lib.rs:252:20
    #7 0x563901457ac0 in clap_lex::RawArgs::new::h15bd37a9b8bbc9f3 /home/joel/.cargo/registry/src/github.com-1ecc6299db9ec823/clap_lex-0.2.4/src/lib.rs:159:9
    #8 0x563901376ede in clap::builder::command::App::try_get_matches_from_mut::h4be4901eee48f906 /home/joel/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-3.2.22/src/builder/command.rs:685:28
    #9 0x5638ff0afcf0 in clap::builder::command::App::get_matches_from::h42775bf325a454cc /home/joel/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-3.2.22/src/builder/command.rs:600:9
    #10 0x5638ff0af719 in clap::builder::command::App::get_matches::hf6df89777d6c8a6e /home/joel/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-3.2.22/src/builder/command.rs:512:9
    #11 0x5638ff0ae6b5 in clap::derive::Parser::parse::hd047da00f7803e2c /home/joel/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-3.2.22/src/derive.rs:81:27
    #12 0x5638ff0ac5a7 in flutter_rust_bridge_codegen::main::h5b09e3c9b76367b1 /b/flutter_rust_bridge/frb_codegen/src/main.rs:12:20
    #13 0x5638ff0b034d in core::ops::function::FnOnce::call_once::h143a6cdd3819f127 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/core/src/ops/function.rs:251:5
    #14 0x5638ff0ac43f in std::sys_common::backtrace::__rust_begin_short_backtrace::hb63e5da4dd063933 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/sys_common/backtrace.rs:122:18
    #15 0x5638ff0b1988 in std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h9ef0f70771746cfd /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/rt.rs:166:18
    #16 0x5639017511ba in core::ops::function::impls::_$LT$impl$u20$core..ops..function..FnOnce$LT$A$GT$$u20$for$u20$$RF$F$GT$::call_once::hcf0f452e35b42714 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/core/src/ops/function.rs:286:13
    #17 0x5639017511ba in std::panicking::try::do_call::h9076463b86fc98c2 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/panicking.rs:464:40
    #18 0x5639017511ba in std::panicking::try::h59a38c38fab81132 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/panicking.rs:428:19
    #19 0x5639017511ba in std::panic::catch_unwind::h024c7f29e5fae637 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/panic.rs:137:14
    #20 0x5639017511ba in std::rt::lang_start_internal::_$u7b$$u7b$closure$u7d$$u7d$::h1bc9c4aefbf9b583 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/rt.rs:148:48
    #21 0x5639017511ba in std::panicking::try::do_call::hf630db2c23823f3c /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/panicking.rs:464:40
    #22 0x5639017511ba in std::panicking::try::h5c6c892f05382366 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/panicking.rs:428:19
    #23 0x5639017511ba in std::panic::catch_unwind::h893ebad4c00d9e60 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/panic.rs:137:14
    #24 0x5639017511ba in std::rt::lang_start_internal::h2fa3ed5bcd048bb3 /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/rt.rs:148:20
    #25 0x5638ff0b18a5 in std::rt::lang_start::hf7344b111aea32dd /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/std/src/rt.rs:165:17
    #26 0x5638ff0ae339 in main (/b/flutter_rust_bridge/target/x86_64-unknown-linux-gnu/debug/flutter_rust_bridge_codegen+0x157339) (BuildId: 67518c91c290ea208b4eb403cd01820de649c532)
    #27 0x7f15a0bbfb74 in __libc_start_main (/lib64/libc.so.6+0x27b74) (BuildId: 08df60634339b221bb854d4e10b7278cafde70c4)
    #28 0x5638ff0459ed in _start (/b/flutter_rust_bridge/target/x86_64-unknown-linux-gnu/debug/flutter_rust_bridge_codegen+0xee9ed) (BuildId: 67518c91c290ea208b4eb403cd01820de649c532)

SUMMARY: MemorySanitizer: use-of-uninitialized-value /rustc/8796e7a9cfd4c5c4f1de15ec1c53994ddf288665/library/core/src/option.rs:924:9 in core::option::Option$LT$T$GT$::map::h38ad6799827d9dcd
Exiting
fzyzcjy commented 1 year ago

Nice catch! So we have two TODOs now:

Looking forward to PR :)

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 1 year ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue.