pacak / cargo-show-asm

cargo subcommand showing the assembly, LLVM-IR and MIR generated for Rust code
Apache License 2.0
715 stars 35 forks source link

Function selection via index broken on v0.2.24 to v0.2.28 #244

Closed zeroflaw closed 10 months ago

zeroflaw commented 10 months ago

I updated to v0.2.28 and had an issue selecting a function. So I had this list :

cargo asm -p exchange_reactor --lib 
 0 "<exchange_reactor::BootstrapReactor as exchange_reactor::Reactor>::poll" [19]
 1 "<exchange_reactor::BootstrapReactor as exchange_reactor::Reactor>::state" [8]
 2 "<exchange_reactor::BootstrapReactor as exchange_reactor::ReactorCold<exchange_reactor::TradingReactor>>::next" [29]
 3 "<exchange_reactor::CompleteReactor as exchange_reactor::Reactor>::poll" [7]
 4 "<exchange_reactor::CompleteReactor as exchange_reactor::Reactor>::state" [7]
 5 "<exchange_reactor::CompleteReactor as exchange_reactor::ReactorCold<exchange_reactor::TradingReactor>>::next" [14]
 6 "<exchange_reactor::ShutdownReactor as exchange_reactor::Reactor>::poll" [19]
 7 "<exchange_reactor::ShutdownReactor as exchange_reactor::Reactor>::state" [8]
 8 "<exchange_reactor::ShutdownReactor as exchange_reactor::ReactorCold<exchange_reactor::TradingReactor>>::next" [83]
 9 "<exchange_reactor::TradingReactor as exchange_reactor::ReactorHot>::next" [49]
10 "<exchange_reactor::TradingRuntime as core::default::Default>::default" [48]
11 "core::ptr::drop_in_place<exchange_reactor::BootstrapReactor>" [6]
12 "core::ptr::drop_in_place<exchange_reactor::CompleteReactor>" [7]
13 "core::ptr::drop_in_place<exchange_reactor::ShutdownReactor>" [6]
14 "exchange_reactor::TradingRuntime::cold_handle" [113]
15 "exchange_reactor::TradingRuntime::new" [50]
16 "exchange_reactor::TradingRuntime::next" [92]
17 "exchange_reactor::TradingRuntime::poll" [87]
18 "exchange_reactor::TradingRuntime::poll::cold" [48]
19 "exchange_reactor::cold_log_error" [66]

I then went to select poll of TradingRuntime using

cargo asm -p exchange_reactor --lib 17

I ended up getting the wrong function being exported:

.section ".text.<exchange_reactor::BootstrapReactor as exchange_reactor::Reactor>::poll","ax",@progbits
        .p2align        4, 0x90
        .type   <exchange_reactor::BootstrapReactor as exchange_reactor::Reactor>::poll,@function
<exchange_reactor::BootstrapReactor as exchange_reactor::Reactor>::poll:
---snip---

rolled back through v0.2.28, v0.2.27, v0.2.26, v0.2.25, v0.2.24, which all suffer from the same issue, with v0.2.23 working as expected. My library is not open-source. The poll function is a trait that is implemented on multiple types. Maybe because they have the same name they are getting confused?

If you struggle to reproduce, I am happy to try to create a minimum example.

zeroflaw commented 10 months ago

fyi it broke on commit 74d69ad I am able to get the correct output if I specify the name e.g.

cargo asm -p exchange_reactor --lib exchange_reactor::TradingRuntime::poll 0
pacak commented 10 months ago

Looking. FWIW one of the easier ways to find exactly which commit breaks the code is using git bisect

pacak commented 10 months ago

I pushed rc-0.2.29 branch, with the fix. You can you confirm the bug is gone for you?

zeroflaw commented 10 months ago

Can confirm branch works as expected. Thanks for the quick fix.

pacak commented 10 months ago

Released 0.2.29

pacak commented 10 months ago

Thank you for the bugreport :heart: