minimap2 icon indicating copy to clipboard operation
minimap2 copied to clipboard

Undefined behaviour

Open armintoepfer opened this issue 1 year ago • 3 comments

Using mm2 v2.26 in pbmm2, I fail at

lchain.c:228:1: runtime error: index -1 out of bounds for type 'const lc_elem_t *[64]' (aka 'const struct lc_elem_s *[64]')

How to reproduce

git clone https://github.com/PacificBiosciences/pbmm2 pbmm2
cd pbmm2
mkdir build
cd build
meson setup --buildtype=debugoptimized -Db_sanitize=address,undefined -Db_lundef=false
ninja
ninja test

armintoepfer avatar Aug 14 '23 09:08 armintoepfer

If I unfold the macros, I get to this line, but not sure if it's the correct line: https://github.com/lh3/minimap2/blob/ace990c381c647d6cf8fae7a4941a7b56fb67ae7/krmq.h#L354

armintoepfer avatar Aug 14 '23 09:08 armintoepfer

See also #1029. I believe this is a false positive of ubsan because itr->stack-1 is never accessed. Nonetheless, I can reopen and merge #1029 just to make ubsan happy.

lh3 avatar Aug 14 '23 13:08 lh3

I would appreciate if the code passes sanitizers. Thank you

armintoepfer avatar Aug 15 '23 08:08 armintoepfer