UserAlphabetIndex1::getIndex() exceed boundaries of index_ data member

14 views
Skip to first unread message

Keren Halabi

unread,
May 23, 2019, 9:29:38 AM5/23/19
to Bio++ Usage Help Forum

Dear Bio++ team,

I noticed that the function UserAlphabetIndex1::getIndex() which returns the item in index_ with the index sometimes tries to access indices beyond the length of index_, which results in return of a random double from some slot in the memory. I attach here an example to reproduce the issue. To trace the issue, I added a breakpoint to UserAlphabetIndex1::getIndex() and saw that in the second call the function via the program, alph_->getStateIndex(state)-1=2, while the largest index in the vector index_ is 1.
Could you please look into it and let me know if it's intentional?

Thanks!
Keren


test_stochastic_mapping.cpp

Keren Halabi

unread,
Jun 2, 2019, 6:52:43 AM6/2/19
to Bio++ Usage Help Forum
Hi dear team,

Is there any update on this question?

Thanks!
Keren

Laurent Guéguen

unread,
Jun 6, 2019, 1:07:40 AM6/6/19
to Bio++ Usage Help Forum
Dear Keren,

it seems to me that the problem is more in alph_->getStateIndex(state)  which returns 3, isn't it?
In the case of BinaryAlphabet, looking at the code I can not see how it can happen.
What is the value of "state"?

Cheers,
laurent

Keren Halabi

unread,
Jun 6, 2019, 3:49:59 AM6/6/19
to Bio++ Usage Help Forum
Dear Laurent,

Indeed, alph_->getStateIndex(state) returns 3.
The value of state is 1, when the issue occurs. 
Please find attached a screenshot of my debugger that shows that, and hopefully more information that could help in understanding the source of the issue. This scenario occurs upon the second call toUserAlphabetIndex1::getIndex() when using the cpp program from my previous post. 
Please let me know if there is any additional information I can provide.

Thanks!
Keren
debugAlpha.JPG

Laurent Guéguen

unread,
Jun 7, 2019, 6:10:37 AM6/7/19
to Bio++ Usage Help Forum
Ok,

the problem is in the contruction of the Alphabet.  In the regular code I cannot see where it comes from.
So is the Alphabet you use the regular BinaryAlphabet? 

Also, in your cpp source, can you output the problem, so that I can backtrack it?

Cheers,
Laurent

Keren Halabi

unread,
Jun 8, 2019, 7:07:28 AM6/8/19
to Bio++ Usage Help Forum
Dear Laurent,

Indeed, I agree that the issue stems from the construction of the alphabet in use. I am using the regular BinaryAlphabet.

I added two lines to the code (lines 54 and 78). In the outcome for line 54, you can see that the index returned for state 1 in the BinaryAlphabet instance is 3. I attach here a screenshot from the debugger that can explain why (the gap and unknown character states precede the actual alphabet states: 0,1). Consequently, you can see in line 78 that the index returned for the UserAlphabetInex1 instance is a double from a random memory cell.
I think that the issue might be solved by changing the order of states in BinaryAlphabet class s.t states 0 and 1 come before the states that represent gaps and unknown characters. If that is the case, I would be happy to change it and pull request.

Cheers,
Keren
debug_reward_mapping.cpp
reg_bin_alpha.JPG

Laurent Guéguen

unread,
Jun 18, 2019, 9:43:35 AM6/18/19
to Bio++ Usage Help Forum
Dear Keren,

sorry for the delay, I am rather busy these days.

Indeed, little bug in Binary, it should be fixed now (on master bpp-seq).

Cheers,
Laurent

Reply all
Reply to author
Forward
Message has been deleted
0 new messages