Skip to content

Fix cs md strlen overrun - #168

Open
PPSherry wants to merge 2 commits into
jguhlin:mainfrom
PPSherry:fix/cs-md-strlen-overrun
Open

Fix cs md strlen overrun#168
PPSherry wants to merge 2 commits into
jguhlin:mainfrom
PPSherry:fix/cs-md-strlen-overrun

Conversation

@PPSherry

@PPSherry PPSherry commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

minimap2 C code calls strlen() on the seq pointer as the first operation in mm_gen_cs_or_MD(). Rust &[u8] slices are not NUL-terminated, so passing seq.as_ptr() directly causes __strlen_avx2 SIMD reads to walk past the
buffer into unmapped pages, triggering SIGSEGV (error 4).

Fix: build a NUL-terminated copy (seq_nul) once per read in the cs||md block and pass seq_nul_ptr to all mm_gen_cs/mm_gen_MD calls.

Also remove redundant CStr::from_ptr(contig.as_ptr()) that re-strlen an already-known-length CStr.

Tested on long-read scNanoATAC-seq data (13.8M reads, exit 0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant