MaciekAber / pysam

Automatically exported from code.google.com/p/pysam
0 stars 0 forks source link

Crash in interactive mode #52

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. run the python shell / ipython
2.
import pysam
s = pysam.Samfile("pysam/tests/ex1.bam", 'rb')
print s.fetch().next()

What is the expected output? 
EAS56_57:6:190:289:82   0   99  None    <<<7<<<;<<<<<<<<8;;<7;4<;<;;;;;94<; 69  CTCAAGGTT
GTTGCAAGGGGGTCTATGTGAACAAA  0   [('MF', 192)]

What do you see instead?
Segmentation fault

What version of the product are you using? On what operating system?
Revision 908699d93235

Please provide any additional information below.
Ubuntu 10.04.1 LTS, Python 2.6.5

No idea what's going wrong though.

Original issue reported on code.google.com by finkerna...@mathematik.uni-marburg.de on 15 Nov 2010 at 5:25

GoogleCodeExporter commented 8 years ago
yes I got the similar problem

>>> import pysam
>>> infile = 'test.bam'
>>> a = pysam.Samfile(infile, 'rb')
>>> len(list(a.fetch()))
4008
>>> b = pysam.Samfile('test.bam', 'rb')
>>> len(list(b.fetch()))
Segmentation fault

Original comment by xi11w...@gmail.com on 24 Nov 2010 at 5:45

GoogleCodeExporter commented 8 years ago
BTW, the testing files for above case were attached.  renamed 'test.bam' to 
'test_pysam.bam' 

Original comment by xi11w...@gmail.com on 24 Nov 2010 at 5:58

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks, can't reproduce with latest branches in default and dev-0.4.

Fixed a bug on how filenames were stored internally in pysam. That might have 
fixed it. Please let me know if it reappears.

Bw,
Andreas

Original comment by andreas....@gmail.com on 1 Feb 2011 at 9:53

GoogleCodeExporter commented 8 years ago
I'm afraid I can still provoke in in revision 5b19336f381d on the dev-0.4 
branch.
Trying to track this down, it crashes in IteratorRow.cnext(), more specifically 
inside bam_iter_read(). Alas, printf() and fprintf(stderr,...) inside of 
bam_iter_read only output something if I'm not running in interactive mode... 
and of course, then it doesn't crash.

What I can see though is that self.fp.x.bam is different. In interactive mode 
it's 0x8, while in non-interactive mode it's a nicely 'random' pointer.

Original comment by finkerna...@mathematik.uni-marburg.de on 9 Feb 2011 at 5:11

GoogleCodeExporter commented 8 years ago
Ok, I'm almost certain it's the filename issue.
If I do 
        store = StderrStore()
        print "opening sam", samfile.filename, mode
        self.fp = samopen( samfile.filename, mode, NULL )
        printf("%p %p %p\n", &self.fp ,&self.fp.x, &self.fp.x.bam)
        store.release()
in IteratorRow.__cinit__, 
I see the correct filename in no interactive mode, and garbage (close by 
garbage.. sometimes my region, sometimes environment variables, sometimes 
binary data) in interactive mode.

Original comment by finkerna...@mathematik.uni-marburg.de on 9 Feb 2011 at 5:22

GoogleCodeExporter commented 8 years ago
Nevermind.
closer inspection of the dev-0.4 track reveals the filename fix isn't in there, 
and the problem indeed disappears in revision 52154bc9d8 (default branch).

Original comment by finkerna...@mathematik.uni-marburg.de on 9 Feb 2011 at 5:32