libvips / nip2

A spreadsheet-like GUI for libvips.
https://libvips.github.io/libvips/
GNU General Public License v2.0
362 stars 13 forks source link

generation & usage of parse.h is race susceptible #49

Closed nieder closed 9 years ago

nieder commented 9 years ago

The creation of the parse.h header is susceptible to a race condition with it being #included by model.c.

Using -j8, I get this failure about 50% of the time:

gcc -DHAVE_CONFIG_H -I. -I..  -I/sw/include   -I/sw/include/libgsf-1 -I/sw/include/glib-2.0 -I/sw/lib/glib-2.0/include -I/sw/include/libxml2 -I/sw/include   -I/sw/include  -I/sw/include/gtk-2.0 -I/sw/lib/gtk-2.0/include -I/sw/include/gtk-2.0 -I/sw/include/pango-1.0 -I/sw/include/atk-1.0 -I/sw/include/cairo -I/sw/include/pango-1.0 -I/sw/include/freetype2 -I/sw/include -I/sw/include/libxml2 -I/sw/include -I/sw/include/glib-2.0 -I/sw/lib/glib-2.0/include -I/opt/X11/include  -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS   -I/sw/include  -g -O2 -MT nip2-model.o -MD -MP -MF .deps/nip2-model.Tpo -c -o nip2-model.o `test -f 'model.c' || echo './'`model.c
model.c:40:10: fatal error: 'parse.h' file not found
#include "parse.h"
         ^
1 error generated.
make[3]: *** [nip2-model.o] Error 1

I've put the compiler command and the error right next to each other here, but they are not adjacent i the build log (as would be expected with a -jN build).

OS X 10.9, using Fink to handle dependencies and nip2 itself. system-make: GNU Make 3.81

jcupitt commented 9 years ago

Here's a very simple way to show the problem:

$ cd nip2-x.x/src
$ rm parse.h
$ make model.o
model.c:40:19: fatal error: parse.h: No such file or directory

ie. the makefile does not know it must bison parse.y to make parse.c and parse.h before it can make model.o. I've tried various things but not found the right combination of rules yet, I'll keep poking.

nieder commented 9 years ago

Adding parse.c to the dependencies of nip2-model.o in src/Makefile, and then make nip2-model.o fixes the failure here. make model.o is not good enough to trigger the bison parser.* rule, apparently. lart libtool

jcupitt commented 9 years ago

I think that's done it, if you get a chance to test that'd be great.

nieder commented 9 years ago

Yeah, removing parse.h and then remaking nip2-model.o w/ a883c22 as the checkout gets parse.h rebuilt.

jcupitt commented 9 years ago

OK, closing, thanks @nieder.