bioperl / bioperl-live-redmine

Legacy tickets migrated from the OBF Redmine issue tracker: http://redmine.open-bio.org
0 stars 0 forks source link

hss memory allocation 1-off error in HMM.xs::HMM_viterbi #66

Open cjfields opened 8 years ago

cjfields commented 8 years ago

Author Name: P. Horton (P. Horton) Original Redmine Issue: 2976, https://redmine.open-bio.org/issues/2976 Original Date: 2009-12-26 Original Assignee: Bioperl Guts


Working with Bioperl-ext version 1.5.1 On Ubuntu with perl v5.10.0, gcc version 4.3.3

% cd bioperl-ext/Bio/Ext/HMM/ % perl Makefile.PL % make

Okay, but

% make test

crashes with

Emission Probability Matrix: 0.160194 0.174757 0.179612 0.160194 0.160194 0.165049 0.0744681 0.0744681 0.12766 0.0425532 0.106383 0.574468 Vitebi Algorithm: glibc detected /usr/bin/perl: malloc(): memory corruption: 0x0a14d3c0 ***\ = Backtrace: === /lib/tls/i686/cmov/libc.so.6[0x400ea276] …

Upon inspection I found what looked to be a code bug in HMM.xs which can be fixed by altering one line. Fixing it case make test to work.

The code bug:

In HMM.xs::HMM_viterbi(class, hmm, seq)

char hss = (char ) malloc(T*sizeof(char));

but in hmmlib.c::viterbi(HMM hmm, char hss, char * obs, int T)

hss[T] = ‘\0’;

Looks like the line in HMM_viterbi should really be

char * hss = (char ) malloc( (T+1) sizeof(char) );

cjfields commented 8 years ago

Original Redmine Comment Author Name: Chris Fields Original Date: 2011-04-14T03:26:28Z


Just a note that Bio::Tools::HMM has moved into it’s own distribution, but it hasn’t been released due to some issues with failing tests.