slact / nchan

Fast, horizontally scalable, multiprocess pub/sub queuing server and proxy for HTTP, long-polling, Websockets and EventSource (SSE), powered by Nginx.
https://nchan.io/
Other
3.01k stars 292 forks source link

subscribers/websocket.c:1210:3: error: 'close_msg' may be used uninitialized in this function [-Werror=maybe-uninitialized] #134

Closed bbigras closed 8 years ago

bbigras commented 8 years ago

I'm trying to build nchan with Docker and I get this error.

My Dockerfile is based on Alpine. I wonder if that's the problem.

cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g   -I src/core -I src/event -I src/event/modules -I src/os/unix -I /tmp/nchan-0.99.5/src -I objs -I src/http -I src/http/modules -I src/http/v2 -I src/mail -I src/stream \
        -o objs/addon/subscribers/websocket.o \
        /tmp/nchan-0.99.5/src/subscribers/websocket.c
/tmp/nchan-0.99.5/src/subscribers/websocket.c: In function 'websocket_respond_status':
/tmp/nchan-0.99.5/src/subscribers/websocket.c:1210:3: error: 'close_msg' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   websocket_send_close_frame(fsub, close_code, close_msg);
   ^
cc1: all warnings being treated as errors
objs/Makefile:1790: recipe for target 'objs/addon/subscribers/websocket.o' failed
make[1]: *** [objs/addon/subscribers/websocket.o] Error 1
make[1]: Leaving directory '/usr/src/nginx-1.9.11'
Makefile:8: recipe for target 'build' failed
make: *** [build] Error 2
slact commented 8 years ago

can you give me the output of cc -v? Its odd that I hadn't picked up this warning.

bbigras commented 8 years ago

It's also possible that I'm doing something wrong. Someone else's Dockerfile builds fine.

$ cc -v
Using built-in specs.
COLLECT_GCC=cc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc-5-20160209/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --enable-libmpx --with-system-zlib --with-isl --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --disable-libssp --enable-gnu-unique-object --enable-linker-build-id --enable-lto --enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu --enable-gnu-indirect-function --disable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 5.3.0 (GCC)
bbigras commented 8 years ago

I think the other Dockerfile could be suppressing this error. It uses -Wno-maybe-uninitialized.

slact commented 8 years ago

Yep. You're not doing anything wrong, it's a legitimate (although not too useful) warning. I'll fix it regardless.

slact commented 8 years ago

Strange, the warning doesn't come up for me (gcc 5.3.0) with -W-maybe-uninitialized .

(incidentally, clang's satic analyzer didn't pick this up either; and technically, the compiler here is incorrect, as it's not possible for close_msg to be unset in that function. I'm guessing your gcc doesn't understand what an assert(0) means for some reason.)

Either way, it should be fixed. Try building from master, and if it's fine i'll tag a new version that includes this and the reload bug fixes.

slact commented 8 years ago

it's fixed.