cocodataset / cocoapi

COCO API - Dataset @ http://cocodataset.org/
Other
6.05k stars 3.75k forks source link

Build break in mapAPI.c #178

Open skelleher opened 6 years ago

skelleher commented 6 years ago

Can't build the tip of master. Uninitialized variable warning treated as error:

../common/maskApi.c: In function 'rleToBbox': ../common/maskApi.c:141:31: warning: 'xp' may be used uninitialized in this function [-Wmaybe-uninitialized] if(j%2==0) xp=x; else if(xp<x) { ys=0; ye=h-1; }

This was introduced by a recent bug fix ( ff4a47150bf666762fa3454335453520e7a041a8 )?

I've tried building the last several commits and none compile for me (Ubuntu 14.04, Python 2.7.6). I see no tag releases; is there a Last Known Good build? Or pre-built binaries I can pip install?

hansen1101 commented 6 years ago

Had the same issue on Ubuntu 16.04. For me checkout of 0d86027 solved the problem.

tyler-e-marshall commented 5 years ago

Just encountered this issue. For me, doing a

pip install cython followed by pip install pycocotools fixed the issue.

pip install pycocotools didn't work because it doesn't list cython as a dependency even though it needs it. Also can't do pip install cython pycocotools because pip doesn't install cython before trying to install pycocotools.

I'd like to mention that I tried hansen's solution but it didn't work for me. I received the same error.

dmankins commented 5 years ago

I don't see why 0d86027 should solve the problem --- that patch doesn't appear to modify maskApi.c (that I can see).

Here is the code line in question (line 140 of common/maskApi.c): if(j%2==0) xp=x; else if(xp<x) { ys=0; ye=h-1; } if j%2 is 0, xp gets set to x. If j%2 is non-zero, an uninitialized xp is compared to x.

This is the only use of xp in the routine! It's safe, because this is in a loop where j is initialized to 0, so the first time through the loop xp will be initialized to x.

x has a value set earlier in the loop on j. To fix the warning, initialize xp to (anything, really, like 0) where it is declared (which is outside the loop on j). The code will give xp the correct value on the 0th pass through the loop on j.