Closed 0xDmtri closed 3 months ago
Thanks for the detailed issue! Would like to confirm that this happens on a clean build (cargo clean
) and with updated and equal versions for all packages, since the code is very sensitive about all of this.
I'd appreciate if you could either provide the bytecode and relevant inputs and environment to reproduce this, or, if not possible, see if you can bisect the commit where this segfault occurs, the range you gave is https://github.com/paradigmxyz/revmc/compare/cec178dcef3ce809c6d567dca9f8122464d5a53d...main.
Thanks for the detailed issue! Would like to confirm that this happens on a clean build (
cargo clean
) and with updated and equal versions for all packages, since the code is very sensitive about all of this.I'd appreciate if you could either provide the bytecode and relevant inputs and environment to reproduce this, or, if not possible, see if you can bisect the commit where this segfault occurs, the range you gave is cec178d...main.
Can confirm that I did cargo clean
as well as tested with debug and release profiles. About deps my alloy-primitives is 7.7 while revmc's is at 7.1.
Im gonna make a repro example repo ser, sounds good. Bisecting commit is also possible yh
@DaniPopes Heres an easy repro that produces Segfault (well at least for me hehe).
Ok, wild fact. It bloody works on my M1 pro mac chip... But it doesnt on my AMD box... Mental.
I think im going insane already, spent 2 weeks debugging all these thing.
Probably related to Revm optimizations? As its the common crate between Reth and Revmc. But then why would it work without opts for Reth but not for Revmc? I am even more confused now...
lscpu:
Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 48 bits physical, 48 bits virtual
Byte Order: Little Endian
CPU(s): 32
On-line CPU(s) list: 0-31
Vendor ID: AuthenticAMD
BIOS Vendor ID: Advanced Micro Devices, Inc.
Model name: AMD Ryzen 9 7950X3D 16-Core Processor
BIOS Model name: AMD Ryzen 9 7950X3D 16-Core Processor Unknown CPU @ 4.2GHz
BIOS CPU family: 107
CPU family: 25
Model: 97
Thread(s) per core: 2
Core(s) per socket: 16
Socket(s): 1
Stepping: 2
Frequency boost: enabled
CPU(s) scaling MHz: 58%
CPU max MHz: 5758.5928
CPU min MHz: 3000.0000
BogoMIPS: 8384.18
Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good
amd_lbr_v2 nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand lahf_lm
cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_
l3 hw_pstate ssbd mba perfmon_v2 ibrs ibpb stibp ibrs_enhanced vmmcall fsgsbase bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma
clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local avx512_bf16 clzero irperf xsaveerptr
rdpru wbnoinvd cppc arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif x2avic v_spec_ct
rl avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid overflow_recov succor smca fsrm flush_l1d amd_lbr_pmc_f
reeze
Virtualization features:
Virtualization: AMD-V
Caches (sum of all):
L1d: 512 KiB (16 instances)
L1i: 512 KiB (16 instances)
L2: 16 MiB (16 instances)
L3: 128 MiB (2 instances)
NUMA:
NUMA node(s): 1
NUMA node0 CPU(s): 0-31
Vulnerabilities:
Gather data sampling: Not affected
Itlb multihit: Not affected
L1tf: Not affected
Mds: Not affected
Meltdown: Not affected
Mmio stale data: Not affected
Reg file data sampling: Not affected
Retbleed: Not affected
Spec rstack overflow: Mitigation; safe RET, no microcode
Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Spectre v2: Mitigation; Enhanced / Automatic IBRS; IBPB conditional; STIBP always-on; RSB filling; PBRSB-eIBRS Not affected; BHI Not affected
Srbds: Not affected
Tsx async abort: Not affected
I can reproduce, but only when optimizing the bytecode, and if I don't add printf
at every instruction. Not sure what's going on, will investigate further
I can reproduce, but only when optimizing the bytecode, and if I don't add
printf
at every instruction. Not sure what's going on, will investigate further
Thats wicked mate haha, if you need any help def lmk, im here to assist!
Maybe an LLVM miscompilation, or some undefined behavior related to MSTORE builtin, because adding noinline
fixes the segfault.
Maybe an LLVM miscompilation, or some undefined behavior related to MSTORE builtin, because adding
noinline
fixes the segfault.
Interesting. I wonder whats causing it in Reth
Don't know, it's unrelated, and a known issue.
After updating the library I started getting
SIGSEGV
. The commit cec178dcef3ce809c6d567dca9f8122464d5a53d still works just fine. It stopped working when REVM was bumped to 12.1.I decided to debug it via GDB, attaching logs:
P.S.
libdexy
is the bytecode I statically linked via:What we can understand from the backtrace (imho):
libdexy
macro-generated function.libdexy
function was called byrevmc_context::EvmCompilerFn::call
.revmc_context::EvmCompilerFn::call_with_interpreter
.revmc_context::EvmCompilerFn::call_with_interpreter_and_memory
.revmc_context
,strategy::simulator
, andrevm
crates leading up to the segmentation fault.strategy::simulator::lil_dexy::find_optimal_inputs
.Locals info:
Mem dump for Frame 1:
Attempted to examine the stack reference but encountered issues with direct dereferencing, hence did mem inspection via
x/16a
command and concluded the following:stack
,stack_len
, andecx
using thex/16a
command.stack_len
showed a length value, and other pointers appeared valid.ecx
also contained a mix of valid pointers and data.Place in code where it panics: https://github.com/paradigmxyz/revmc/blob/main/crates/revmc-context/src/lib.rs#L271