NetworkBlockDevice / nbd

Network Block Device
GNU General Public License v2.0
450 stars 116 forks source link

Sporadic build failure with parallel make due to implicit dependency in Makefile.am #140

Closed jan-krieg closed 1 year ago

jan-krieg commented 1 year ago

nbdtab_lexer.l includes (and thus depends on) nbdtab_parser.tab.h, which in turn is dynamically generated during the build from nbdtab_parser.y (via bison). However, this dependency is currently only implicit in Makefile.am. Building nbd with parallel make can thus fail via a race condition, where nbdtab_lexer.l is processed before nbdtab_parser.tab.h has been created.

While parallel make seems to work fine most of the time, I've actually run into this issue with failed builds in practice, when fixing a bug in (and thus repeatedly emerging) Gentoo's live ebuild for nbd while my hard drive was under load from another task (which seems to have triggered the race condition). Looking into it, I could then also reproduce the issue by manually cloning the git repo and running ./autogen.sh, ./configure, and make -j8 -l8: nbd_failed_parallel_make.log

I'll add a pull request that solves this issue in my view.

PS: An artificial way to trigger the race condition is to run git clean -dfxq && ./autogen.sh && ./configure && sed -i 's/^\tbison/\tsleep 10; bison/' Makefile && make -j8 -l8