segmentation fault attempting to view header in json format

35 views
Skip to first unread message

Joshua Randall

unread,
Jan 2, 2018, 10:29:27 AM1/2/18
to sambamba-discussion
I have been getting a segmentation fault when attempting to use sambamba view to get the header of a BAM (or SAM) in JSON format. Getting the header in `sam` or `msgpack` format appears to work, but json format causes a segfault for most versions I've tried.

I initially tried using the guix package on my own data (running inside a docker container produced using `guix pack -f docker`, but I found that test data packaged with sambamba source triggers the issue as well, and it also occurs on my debian system with the guix package installed.

Can anyone else reproduce this problem?
$ /gnu/store/ahcvy79b8gmjg32kbi1cn6lylls2zjzx-sambamba-0.6.5/bin/sambamba view -H -f json test/issue_204.bam
Segmentation fault


Here is the backtrace of the segfault using gdb: 

$ gdb --args /gnu/store/ahcvy79b8gmjg32kbi1cn6lylls2zjzx-sambamba-0.6.5/bin/sambamba view -H -f json test/issue_204.bam
GNU gdb (Debian 7.7.1+dfsg-5) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /gnu/store/ahcvy79b8gmjg32kbi1cn6lylls2zjzx-sambamba-0.6.5/bin/sambamba...(no debugging symbols found)...done.
(gdb) run
Starting program: /gnu/store/ahcvy79b8gmjg32kbi1cn6lylls2zjzx-sambamba-0.6.5/bin/sambamba view -H -f json test/issue_204.bam
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/gnu/store/3h31zsqxjjg52da5gp3qmhkh4x8klhah-glibc-2.25/lib/libthread_db.so.1".
[New Thread 0x7ffff70eb700 (LWP 29949)]
[New Thread 0x7ffff68ea700 (LWP 29950)]

Program received signal SIGSEGV, Segmentation fault.
0x00000000005851d0 in std.json.JSONValue.str() ()
(gdb) bt
#0  0x00000000005851d0 in std.json.JSONValue.str() ()
#1  0x00000000004c4b1c in bio.sam.header.SamHeader.__T6toJsonTDFAxaZvZ.toJson() ()
#2  0x00000000004b3849 in bio.sam.header.SamHeader.toString() ()
#3  0x00000000004b3301 in std.format.__T14formattedWriteTS3std5stdio4File17LockingTextWriterTaTC3bio3sam6header9SamHeaderZ.formattedWrite() ()
#4  0x00000000004fe0ad in sambamba.utils.view.headerserializer.HeaderJsonSerializer.writeln() ()
#5  0x0000000000438f17 in sambamba.view.__T12sambambaMainTC3bio3bam6reader9BamReaderZ.sambambaMain() ()
#6  0x0000000000437ccd in sambamba.view.view_main() ()
#7  0x00000000005b2e2f in rt.dmain2._d_run_main() ()
#8  0x00000000005b2df4 in rt.dmain2._d_run_main() ()
#9  0x00000000005b2d1d in _d_run_main ()
#10 0x00007ffff710c4f0 in __libc_start_main () from /gnu/store/3h31zsqxjjg52da5gp3qmhkh4x8klhah-glibc-2.25/lib/libc.so.6
#11 0x000000000040639a in _start ()


I have also downloaded a number of binary release, and all the ones I have tested (v0.5.0-alpha, v0.5.9. v0.6.5, v0.6.6) appear to have the same segfault issue, with the exception of the newest binary (v0.6.7) which gives this error instead of throwing a segfault:

$ ./sambamba_v0.6.7 view -H -f json test/issue_204.bam
core.exception.RangeError@BioD/bio/sam/header.d(654): Range violation
----------------

The same issue occurs when using `--with-header` instead of `--header`, but when not outputting the header, JSON output appears to work just fine:
$ ./sambamba_v0.6.7 view -f json test/issue_204.bam | wc -l
559


Any ideas? If JSON header output from sambamba view works for others on the `test/issue_204.bam` file, that would be useful to know, as in that case there must be something about my system that is triggering this issue. 

Pjotr Prins

unread,
Jan 2, 2018, 12:37:18 PM1/2/18
to Joshua Randall, sambamba-discussion
Hi Joshua,

Thanks for reporting. I am getting the same error and created a github
issue:

https://github.com/biod/sambamba/issues/331

I'll look into it.

Pj.
Reply all
Reply to author
Forward
0 new messages