iustin / pyxattr

A python module for accessing filesystem Extended Attributes
https://pyxattr.k1024.org/
GNU Lesser General Public License v2.1
31 stars 14 forks source link

compile fails on docker python:2.7 #13

Closed nichenke closed 8 years ago

nichenke commented 8 years ago

When using the default docker image for python2.7, the compile fails in a really odd way. I'm not sure if this is a tricky thing for pyxattr or a problem with the docker python:2.7 images as compared to Debian Jessie.

Reproduce:

docker run --rm -it python:2.7 bash -c "apt-get update && apt-get install -y attr-dev && pip install pyxattr"

Error:

xattr.c: In function ‘pyremovexattr’:
xattr.c:229:13: error: ‘tgt’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
     else if (tgt->type == T_LINK)
             ^
xattr.c:784:14: note: ‘tgt’ was declared here
     target_t tgt;
              ^

This seems to work just fine on the official jessie image

docker run --rm -it debian:jessie bash -c "apt-get update && apt-get install -y attr-dev python-pip python-dev && pip install pyxattr"

...snipped..

Running setup.py install for pyxattr building 'xattr' extension x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -D_XATTR_VERSION="0.5.5" -D_XATTR_AUTHOR="Iustin Pop" -D_XATTR_EMAIL="iustin@k1024.org" -I/usr/include/python2.7 -c xattr.c -o build/temp.linux-x86_64-2.7/xattr.o -Wall -Werror x86_64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security build/temp.linux-x86_64-2.7/xattr.o -lattr -o build/lib.linux-x86_64-2.7/xattr.so

Successfully installed pyxattr

iustin commented 8 years ago

Oh, thanks, this was quite an interesting issue! This looks to be a GCC warning that is only triggered in -O3 mode. The default image has -O2 as you pasted above, but the python2.7 image has the following command line:

# python setup.py  build
running build
running build_ext
building 'xattr' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC …

Note the -O3 which follows the default -O2. If I remove that, the warning disappears. The reason why it happens is that gcc estimates correctly - there are some code paths where that variable is not initialized, but the code flow ensure they won't be reached; however, gcc is not able to verify this, so it emits this warning. I'll have a trivial fix out soon.

Thanks for reporting!

iustin commented 8 years ago

Note to self: a very good discussionon why whis happens with -O3 but not with -O2 is at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60165.

iustin commented 7 years ago

FYI, this was released in 0.6.0, and is in pyxattr. Didn't check if docker image works though.