BenchmarkDotNet icon indicating copy to clipboard operation
BenchmarkDotNet copied to clipboard

Segmentation fault on basic benchmark

Open YaslePoy opened this issue 4 months ago • 6 comments

I used BenchmarkDotNet to find the difference between using if i == -1 someone else list[i] and list[i+1], but on Ubuntu and Fedora (VM), there were some problems. When I launched the benchmark, it started, but after the "AfterAll" section, "Segmentation Fault" was written in Ubuntu 25.04, and nothing else happened, just the program finished on Fedora Workstation 42. However, there were no problems on Windows.

If you want to reproduce my problem, you can clone the repository and run the mROABenchmark project. There are no unsafe codes that could cause this error.

YaslePoy avatar Aug 16 '25 10:08 YaslePoy

Hi @YaslePoy

Could you please try to disable the DisassemblyDiagnoser to see if it helps?

https://github.com/YaslePoy/mROA/blob/dfad8b91417c0a61bed5212e54d33d457ecdfec1/mROA.Benchmark/MethodAccess.cs#L9C2-L9C22

adamsitnik avatar Aug 19 '25 08:08 adamsitnik

@adamsitnik I don't know why, but it works. Thank you. But it doesn't work only when using List<T>. When I rewrite it to T[], it works anyway. Still, it's strange why it behaves that way. Are there any suggestions for avoiding such problems in the future, or is this some kind of error in the runtime or benchmark?

YaslePoy avatar Aug 19 '25 09:08 YaslePoy

I mean that it does not work with that implementation, but works with last one

YaslePoy avatar Aug 19 '25 09:08 YaslePoy

@YaslePoy the disassembler is using some very low level APIs designed for the debuggers. You might be hitting a BenchmarkDotNet or a .NET runtime bug.

Which .NET version are you using?

adamsitnik avatar Aug 19 '25 09:08 adamsitnik

@adamsitnik benchmark project uses 9, last 9.0.8, but main project uses 2.1 standard

YaslePoy avatar Aug 19 '25 09:08 YaslePoy

May it happen because of different implementations of lists in newer versions of the runtime?

YaslePoy avatar Aug 19 '25 09:08 YaslePoy