Likely race condition in build system related to generated.tar.gz #1039

Closed
opened 2026-10-05 04:59:48 +02:00 by adam · 3 comments
Owner

Hi,

We switched to cmake in building znc v1.9.0 and are using the following options:

cmake .. \
    -DWANT_PYTHON=yes \
    -DWANT_PERL=yes \
    -DWANT_TCL=yes

It works fine single threaded, but in multi-threaded make, it intermittently fails with the following error:

#11 6.182 [ 81%] Generating swigperlrun.h, ZNC.pm, modperl_biglib.cpp, perlfunctions.cpp
#11 6.184 [ 81%] Built target po_admindebug_de_DE
#11 6.184 [ 81%] Built target po_admindebug_el_GR
#11 6.184 [ 81%] Built target po_admindebug_es_ES
#11 6.188 [ 81%] Generating swigpyrun.h, znc_core.py, modpython_biglib.cpp, pyfunctions.cpp
#11 6.188 [ 81%] Generating swigperlrun.h, ZNC.pm, modperl_biglib.cpp, perlfunctions.cpp
#11 6.189 [ 81%] Generating swigperlrun.h, ZNC.pm, modperl_biglib.cpp, perlfunctions.cpp
#11 6.191 CMake Error: Problem with archive_write_header(): Can't create 'modperl_biglib.cpp'
#11 6.191 CMake Error: Current file: modperl_biglib.cpp
#11 6.191 CMake Error: Problem extracting tar: /tmp/znc/modules/modperl/generated.tar.gz
#11 6.191 make[2]: *** [modules/modperl/CMakeFiles/modperl_functions.dir/build.make:73: modules/modperl/swigperlrun.h] Error 1
#11 6.191 make[2]: *** Deleting file 'modules/modperl/swigperlrun.h'
#11 6.191 make[1]: *** [CMakeFiles/Makefile2:3868: modules/modperl/CMakeFiles/modperl_functions.dir/all] Error 2
#11 6.191 make[1]: *** Waiting for unfinished jobs....
#11 6.194 [ 81%] Built target modperl_swig
#11 6.198 [ 81%] Built target modperl_swigruntime
#11 6.200 [ 81%] Built target modpython_swig
#11 6.200 make: *** [Makefile:136: all] Error 2

It sometimes succeeds, and sometimes fails, suggesting a race condition in parallel build steps.

For reference, here's the Dockerfile we're using: https://github.com/linuxserver/docker-znc/blob/55732d46ad76283f425785eb8c5cbe641431ffdf/Dockerfile
Here's a failing build: https://ci.linuxserver.io/blue/organizations/jenkins/Docker-Pipeline-Builders%2Fdocker-znc/detail/1.9.0/1/pipeline/#step-135-log-1998
And here's a succeeding build with the same Dockerfile, just a different run: https://ci.linuxserver.io/blue/organizations/jenkins/Docker-Pipeline-Builders%2Fdocker-znc/detail/PR-49/1/pipeline

For now we set it to build single threaded and it seems to succeed every time.

Thanks

PS. I just realized we already updated the above linked Dockerfile to remove the env for MAKEFLAGS="-j4", which causes the intermittent issue

Hi, We switched to cmake in building znc v1.9.0 and are using the following options: ``` cmake .. \ -DWANT_PYTHON=yes \ -DWANT_PERL=yes \ -DWANT_TCL=yes ``` It works fine single threaded, but in multi-threaded make, it intermittently fails with the following error: ``` #11 6.182 [ 81%] Generating swigperlrun.h, ZNC.pm, modperl_biglib.cpp, perlfunctions.cpp #11 6.184 [ 81%] Built target po_admindebug_de_DE #11 6.184 [ 81%] Built target po_admindebug_el_GR #11 6.184 [ 81%] Built target po_admindebug_es_ES #11 6.188 [ 81%] Generating swigpyrun.h, znc_core.py, modpython_biglib.cpp, pyfunctions.cpp #11 6.188 [ 81%] Generating swigperlrun.h, ZNC.pm, modperl_biglib.cpp, perlfunctions.cpp #11 6.189 [ 81%] Generating swigperlrun.h, ZNC.pm, modperl_biglib.cpp, perlfunctions.cpp #11 6.191 CMake Error: Problem with archive_write_header(): Can't create 'modperl_biglib.cpp' #11 6.191 CMake Error: Current file: modperl_biglib.cpp #11 6.191 CMake Error: Problem extracting tar: /tmp/znc/modules/modperl/generated.tar.gz #11 6.191 make[2]: *** [modules/modperl/CMakeFiles/modperl_functions.dir/build.make:73: modules/modperl/swigperlrun.h] Error 1 #11 6.191 make[2]: *** Deleting file 'modules/modperl/swigperlrun.h' #11 6.191 make[1]: *** [CMakeFiles/Makefile2:3868: modules/modperl/CMakeFiles/modperl_functions.dir/all] Error 2 #11 6.191 make[1]: *** Waiting for unfinished jobs.... #11 6.194 [ 81%] Built target modperl_swig #11 6.198 [ 81%] Built target modperl_swigruntime #11 6.200 [ 81%] Built target modpython_swig #11 6.200 make: *** [Makefile:136: all] Error 2 ``` It sometimes succeeds, and sometimes fails, suggesting a race condition in parallel build steps. For reference, here's the Dockerfile we're using: https://github.com/linuxserver/docker-znc/blob/55732d46ad76283f425785eb8c5cbe641431ffdf/Dockerfile Here's a failing build: https://ci.linuxserver.io/blue/organizations/jenkins/Docker-Pipeline-Builders%2Fdocker-znc/detail/1.9.0/1/pipeline/#step-135-log-1998 And here's a succeeding build with the same Dockerfile, just a different run: https://ci.linuxserver.io/blue/organizations/jenkins/Docker-Pipeline-Builders%2Fdocker-znc/detail/PR-49/1/pipeline For now we set it to build single threaded and it seems to succeed every time. Thanks PS. I just realized we already updated the above linked Dockerfile to remove the env for `MAKEFLAGS="-j4"`, which causes the intermittent issue <!-- github-sync-id:2149727215 -->
adam closed this issue 2026-10-05 04:59:49 +02:00
Author
Owner

I'm always running with -j20 without any issue.

Your Dockerfile seems reasonable, more or less.

jq -r 'first(.[] | select(.name | contains("-rc") | not)) | .name');

Consider filtering out alpha/beta as well.

Because generated.tar.gz exists in the tarball you're downloading, you're not using swig at all, no need to install it. But since the generated.tar.gz is there already, I don't see how it can be racing with anything.

I see this line twice in your log:

#11 6.188 [ 81%] Generating swigperlrun.h, ZNC.pm, modperl_biglib.cpp, perlfunctions.cpp
#11 6.189 [ 81%] Generating swigperlrun.h, ZNC.pm, modperl_biglib.cpp, perlfunctions.cpp

Does it somehow try to run the exact same extraction twice in parallel? That seems like bug in cmake.

You can remove both generated.tar.gz files after unpacking, then cmake will actually use swig you installed instead, maybe that'll be less racy?

I'm always running with -j20 without any issue. Your Dockerfile seems reasonable, more or less. > jq -r 'first(.[] | select(.name | contains("-rc") | not)) | .name'); Consider filtering out alpha/beta as well. Because generated.tar.gz exists in the tarball you're downloading, you're not using swig at all, no need to install it. But since the generated.tar.gz is there already, I don't see how it can be racing with anything. I see this line twice in your log: ``` #11 6.188 [ 81%] Generating swigperlrun.h, ZNC.pm, modperl_biglib.cpp, perlfunctions.cpp #11 6.189 [ 81%] Generating swigperlrun.h, ZNC.pm, modperl_biglib.cpp, perlfunctions.cpp ``` Does it somehow try to run the exact same extraction twice in parallel? That seems like bug in cmake. You can remove both generated.tar.gz files after unpacking, then cmake will actually use swig you installed instead, maybe that'll be less racy? <!-- github-comment-id:1961905358 -->
Author
Owner

Or try using ninja instead of make. Is that also racy?

Or try using ninja instead of make. Is that also racy? <!-- github-comment-id:1961925236 -->
Author
Owner

Thanks so much for looking into it and for the suggestions.

I just did over a dozen local multi-threaded builds and they all succeeded. When I opened this issue, they were failing about half the time. You might be right that perhaps it was a cmake bug that since got fixed. We do install cmake from pypi so it does get updated frequently.

We're updating our trigger to ignore -beta and -alpha tags as well.

Thanks

Thanks so much for looking into it and for the suggestions. I just did over a dozen local multi-threaded builds and they all succeeded. When I opened this issue, they were failing about half the time. You might be right that perhaps it was a cmake bug that since got fixed. We do install cmake from pypi so it does get updated frequently. We're updating our trigger to ignore `-beta` and `-alpha` tags as well. Thanks <!-- github-comment-id:2020580680 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/znc#1039