Snapcraft fails to run cmake when running inside docker (Classic confinement)


In snapcraft 2.43.1, the snapcraft command fails when executing cmake (or at least that is what the error message says). The same snapcraft.yaml builds fine directly on the host machine and the cmake command executes fine on both the host and in the docker instance. Something seems to be going wrong in how snapcraft is launching cmake and getting the result.

The error message is:
Failed to run 'cmake /home/dev/src/parts/libeigen/src -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=Release' for 'libeigen': Exited with code -11. Verify that the part is using the correct parameters and try again.

I created a wrapper around cmake that runs strace cmake, but this never seems to get executed, or at least the output file isn’t there.

On the other hand, when i strace snapcraft itself, I see the follow entry that does make it look like cmake was succesfully run:

31125 execve("/usr/bin/cmake", ["cmake", "/home/dev/src/parts/libeigen/src", "-DCMAKE_INSTALL_PREFIX=", "-DCMAKE_BUILD_TYPE=Release"], [/* 36 vars */]) = 0

This problem is readily duplicatable on all of our development machines and seems to be the result of a recent change in snapcraft. I haven’t yet examined the release notes / source of snapcraft to see what it is yet, and I would appreciate if anyone has some insight.

Here is a download of the entire strace file:


I have narrowed down the problem a bit and I am continuing to debug. The issue is that this version of snapcraft sets the LD_LIBRARY_PATH before running cmake to:


where the existing $LD_LIBRARY_PATH is empty

If I manually set the LD_LIBRARY_PATH to the same value in the container itself outside of snapcraft and call cmake, then I get a segmentation fault.

rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
— SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=0} —

If I include the actual lib directories of the system running in docker before the paths setup by snapcraft, then CMAKE works. It seems like there is some incompatibility in the dynamic libraries that cmake uses on the host system and the ones that LD_LIBRARY_PATH is forcing it to access in the snap core files.


The included in the snap core seems to be either part of the problem or the entire problem. I have created a temporary directory that has all the lib files required by cmake. As long as I’m using the file from the system itself, everything works fine. When I use the from the snap core directory, then nothing on the system that uses libc works and I get Bus errors. Oddly, the file size of the two libc so files are exactly the same (1868984), but they have different modification dates and times and different md5sums.

I should have mentioned earlier that this also seems to be a problem with classic confinement only. It looks like only when building in classic confinement does snapcraft set that LD_LIBRARY_PATH.