[Cbc] callCbc1 - Problem in callCbc1

John Forrest john.forrest at fastercoin.com
Tue Feb 24 10:18:32 EST 2015


Christian,

You are correct - thanks.

Modifying code to be
   char * input = CoinStrdup(input2 ? input2 : "") ;

should fix so a null input2 will be OK.

I will get it into svn when I have fixed a Git problem.

John Forrest

On 24/02/15 13:35, Christian Troost wrote:
> Dear CBC Team,
>
> we have an application that uses CBC to solve many mixed integer
> problems one after the other. When searching for an ominous segmentation
> fault I ran the application through valgrind memcheck, which reported
> various invalid reads and an occasional invalid write in callCbc1 (the
> innermost of the wrappers of this name).
>
> Upon inspecting the function I found the following problem:
>
> If I understood the logic of the code correctly, then the line
>
>          bool blank = input[0] == '0';
>
> should rather read
>
>          bool blank = input[0] == ' ';
>
> because you are looking for a potential blank at the beginning of the
> argument string, not for a literal 0.
>
> Am I right with this assumption?
>
> At least, when I corrected accordingly, the invalid memory access
> disappeared except for occasional invalid reads at
>
> length = strlen(input)
>
> This however seems related to the valgrind problem discussed on
> https://bugzilla.redhat.com/show_bug.cgi?id=678518 and does disappear
> when running valgrind with
>
> --partial-loads-ok=yes
>
>
> (Still I wonder whether an empty/NULL input2 wouldn't cause a problem
> here, because input is not checked before being used in strlen.)
>
> Best,
>
> Christian
>
>
> _______________________________________________
> Cbc mailing list
> Cbc at list.coin-or.org
> http://list.coin-or.org/mailman/listinfo/cbc
>
>



More information about the Cbc mailing list