japaric / cargo-call-stack

Whole program static stack analysis
Apache License 2.0
560 stars 50 forks source link

BUG: expected a thumb tag at 0xacf9 but found another data tag #96

Open geonnave opened 1 year ago

geonnave commented 1 year ago

I am running call-stack towards a cortex-m4 target that uses a few cryptographic libraries (my repo is edhoc-rs).

When I run it, I get several warnings and then an error telling that it is a bug. Here are the relevant logs:

$ cd examples/edhoc-rs-no_std  # and then manually disable features I do not want enabled

$ cargo call-stack --target="thumbv7em-none-eabihf" --features="rust-psa, rtt" --bin edhoc-rs-no_std

  (... compilation logs ...)

[2023-05-02T09:57:33Z WARN  cargo_call_stack] no type information for `verify_header`
[2023-05-02T09:57:33Z WARN  cargo_call_stack] no type information for `verify_chain`

  (... truncated ...)

[2023-05-02T09:57:33Z WARN  cargo_call_stack] no type information for `mbedtls_sha512_update`
[2023-05-02T09:57:33Z WARN  cargo_call_stack] no type information for `mbedtls_sha512_finish`
[2023-05-02T09:57:33Z WARN  cargo_call_stack] no type information for `mbedtls_sha512`
[2023-05-02T09:57:33Z WARN  cargo_call_stack] assuming that asm!("bkpt #0xab") does *not* use the stack in `rust_begin_unwind`
[2023-05-02T09:57:33Z WARN  cargo_call_stack] assuming that asm!("push {r4, lr}\0Asub sp, sp, #16\0Aadd r4, sp, #8\0Astr r4, [sp]\0Abl __udivmoddi4\0Aldr r2, [sp, #8]\0Aldr r3, [sp, #12]\0Aadd sp, sp, #16\0Apop {r4, pc}") does *not* use the stack in `__aeabi_uldivmod`
[2023-05-02T09:57:33Z WARN  cargo_call_stack] assuming that asm!("bkpt #0xab") does *not* use the stack in `_ZN15edhoc_rs_no_std18__cortex_m_rt_main17h19cb218f62f79732E`
[2023-05-02T09:57:33Z WARN  cargo_call_stack] assuming that asm!("bkpt #0xab") does *not* use the stack in `_ZN50_$LT$$RF$mut$u20$W$u20$as$u20$core..fmt..Write$GT$9write_str17he7c9fdd55c30b43cE`
[2023-05-02T09:57:33Z WARN  cargo_call_stack] assuming that asm!("bkpt #0xab") does *not* use the stack in `_ZN50_$LT$$RF$mut$u20$W$u20$as$u20$core..fmt..Write$GT$10write_char17h63faa3907ef7263bE`
[2023-05-02T09:57:34Z WARN  cargo_call_stack] no stack usage information for `verify_chain`
[2023-05-02T09:57:34Z WARN  cargo_call_stack] no stack usage information for `buffer_alloc_free`
[2023-05-02T09:57:34Z WARN  cargo_call_stack] `buffer_alloc_free` performs an indirect function call and there's no type information about the operation
[2023-05-02T09:57:34Z WARN  cargo_call_stack] no stack usage information for `buffer_alloc_calloc`
[2023-05-02T09:57:34Z WARN  cargo_call_stack] `buffer_alloc_calloc` performs an indirect function call and there's no type information about the operation
[2023-05-02T09:57:34Z WARN  cargo_call_stack] no stack usage information for `mbedtls_memory_buffer_alloc_init`
[2023-05-02T09:57:34Z WARN  cargo_call_stack] `mbedtls_calloc` performs an indirect function call and there's no type information about the operation
[2023-05-02T09:57:34Z WARN  cargo_call_stack] `mbedtls_free` performs an indirect function call and there's no type information about the operation
[2023-05-02T09:57:34Z WARN  cargo_call_stack] `mbedtls_platform_zeroize` performs an indirect function call and there's no type information about the operation
[2023-05-02T09:57:34Z WARN  cargo_call_stack] no stack usage information for `psa_start_key_creation.constprop.0`
[2023-05-02T09:57:34Z WARN  cargo_call_stack] no stack usage information for `psa_key_algorithm_permits`
[2023-05-02T09:57:34Z WARN  cargo_call_stack] no stack usage information for `psa_get_and_lock_key_slot_with_policy.part.0`
[2023-05-02T09:57:34Z WARN  cargo_call_stack] no stack usage information for `psa_cipher_setup`
[2023-05-02T09:57:34Z WARN  cargo_call_stack] no stack usage information for `psa_verify_internal.part.0`
[2023-05-02T09:57:34Z WARN  cargo_call_stack] no stack usage information for `psa_validate_optional_attributes`
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `Data`,
 right: `Thumb`: BUG: expected a thumb tag at     0x71ed but found another data tag', /home/gfedrech/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-call-stack-0.1.15/src/thumb.rs:60:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

And also another set of logs when I compile it using a different crypto backend (cryptocell instead of psa)

$ cd examples/edhoc-rs-no_std  # and then manually disable features I do not want enabled

$ cargo call-stack --target="thumbv7em-none-eabihf" --features="rust-cryptocell310, rtt" --bin edhoc-rs-no_std

  (... compilation logs ...)

[2023-05-02T10:02:21Z WARN  cargo_call_stack] no type information for `hashUpdate`
[2023-05-02T10:02:21Z WARN  cargo_call_stack] no type information for `CRYS_HASH_Init`
[2023-05-02T10:02:21Z WARN  cargo_call_stack] no type information for `CRYS_HASH_Update`

  (... truncated ... )

[2023-05-02T10:02:21Z WARN  cargo_call_stack] no type information for `SaSi_HalMaskInterrupt`
[2023-05-02T10:02:21Z WARN  cargo_call_stack] no type information for `SaSi_HalWaitInterrupt`
[2023-05-02T10:02:21Z WARN  cargo_call_stack] no type information for `SaSi_PalPowerSaveModeSelect`
[2023-05-02T10:02:21Z WARN  cargo_call_stack] assuming that asm!("bkpt #0xab") does *not* use the stack in `_ZN50_$LT$$RF$mut$u20$W$u20$as$u20$core..fmt..Write$GT$10write_char17h63faa3907ef7263bE`
[2023-05-02T10:02:21Z WARN  cargo_call_stack] assuming that asm!("bkpt #0xab") does *not* use the stack in `_ZN15edhoc_rs_no_std18__cortex_m_rt_main17h7519564f6efe4eb5E`
[2023-05-02T10:02:21Z WARN  cargo_call_stack] assuming that asm!("bkpt #0xab") does *not* use the stack in `_ZN50_$LT$$RF$mut$u20$W$u20$as$u20$core..fmt..Write$GT$9write_str17he7c9fdd55c30b43cE`
[2023-05-02T10:02:21Z WARN  cargo_call_stack] assuming that asm!("bkpt #0xab") does *not* use the stack in `rust_begin_unwind`
[2023-05-02T10:02:21Z WARN  cargo_call_stack] no stack usage information for `hashUpdate`
[2023-05-02T10:02:21Z WARN  cargo_call_stack] `hashUpdate` performs an indirect function call and there's no type information about the operation
thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `Data`,
 right: `Thumb`: BUG: expected a thumb tag at     0x5fad but found another data tag', /home/gfedrech/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-call-stack-0.1.15/src/thumb.rs:60:21
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Also, in both cases, I updated the workspace's Cargo.toml to have lto = 'fat' in the release profile.