Skip to content

Seeding: fix invalid index returned after binary search for hit

Roel Aaij requested to merge seeding_fix_binary_search into master

Drive-by fix as part of #452 (closed)

When investigating the Drell-Yan issue reported in #452 (closed) using the reproducer (thanks @rowina!), I an assert in the seeding (backtrace at the bottom). This MR fixes the assert by never returning the "end" index after a binary search for a hit.

@lohenry, @ahennequ could you verify that this fix is correct?

backtrace:

python: ../device/event_model/SciFi/include/SciFiEventModel.cuh:231: unsigned int SciFi::Hits_t<T>::channel(unsigned int) const [with T = const char]: Assertion `index < m_total_number_of_hits' failed.

Thread 2 "python" received signal SIGABRT, Aborted.
[Switching to Thread 0x7fffb1084700 (LWP 5093)]
0x00007ffff6b38387 in raise () from /lib64/libc.so.6
(gdb) bt
#0  0x00007ffff6b38387 in raise () from /lib64/libc.so.6
#1  0x00007ffff6b39a78 in abort () from /lib64/libc.so.6
#2  0x00007ffff6b311a6 in __assert_fail_base () from /lib64/libc.so.6
#3  0x00007ffff6b31252 in __assert_fail () from /lib64/libc.so.6
#4  0x00007fffb72cfcdc in SciFi::Hits_t<char const>::channel (this=this@entry=0x7fffb1082ba0, index=index@entry=2018) at ../device/event_model/SciFi/include/SciFiEventModel.cuh:231
#5  0x00007fffb7369e2f in SciFi::Hits_t<char const>::id (index=2018, this=0x7fffb1082ba0) at ../device/event_model/SciFi/include/SciFiEventModel.cuh:253
#6  (anonymous namespace)::make_trackXZ (scifi_hits=..., zone_offset=0x7fffb1080d10, multiHitComb=..., chi2ndof=chi2ndof@entry=-nan(0x7f8000)) at ../device/SciFi/hybridseeding/src/seed_xz.cu:72
#7  0x00007fffb736a486 in operator() (__closure=__closure@entry=0x7fffb1080d90, ptr=ptr@entry=0x7fffb1080e10) at ../device/SciFi/hybridseeding/src/seed_xz.cu:382
#8  0x00007fffb736ac4f in shared_or_global<float, seed_xz::seed_xz(Parameters)::<lambda(float*)> >(unsigned int, unsigned int, float *, float *, unsigned int *, const struct {...} &) (size=size@entry=513, max_size=max_size@entry=1800, 
    shared_ptr=shared_ptr@entry=0x7fffb1080e10, global_base_ptr=<optimized out>, global_count=<optimized out>, f=...) at ../device/utils/memory/include/memory_optim.cuh:22
#9  0x00007fffb736aef4 in seed_xz::seed_xz (parameters=...) at /cvmfs/lhcb.cern.ch/lib/lcg/releases/cppgsl/3.1.0-7a1b6/x86_64-centos7-gcc12-dbg/include/gsl/span:690

Merge request reports