patchelf warning / binary segfaults

Bug #1753995 reported by Laurent Sesquès
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Snapcraft
New
Undecided
Unassigned

Bug Description

Hi,

I'm trying to snap telegraf (https://github.com/influxdata/telegraf), which is written in go.
At the prime step, I get the following messages:

[...]
Priming telegraf
patchelf: cannot find section ''
Failed to update '/home/ubuntu/git/dev/telegraf/prime/bin/telegraf'. Retrying after stripping the .note.go.buildid from the elf file.
Snapping 'telegraf' -
Snapped telegraf_1.5.2_amd64.snap

After installing and running the snap, it quickly enters Failed state (inactive (dead) (Result: core-dump)).
syslog messages: https://pastebin.canonical.com/p/vzy6Pk9m5z/
dmesg: https://pastebin.canonical.com/p/PQJXM7n8Cv/
systemd service configuration (automatically generated): https://pastebin.canonical.com/p/qDp7ZbSwGN/
snapcraft file: https://pastebin.canonical.com/p/FQYWBWy25N/

This is using the stable snapcraft snap, 2.39.2 rev 1177 at the moment.
The same problem does not happen with snapcraft 2.34+17.10 (deb from archives on an artful machine).

This look very similar to lp:1736861, which is 'fix released'.
I tried using snapcraft from --channel edge/patchelf-go. Got a warning:

Files in this part are going to be patched to execute correctly on diverse environments.
To disable this behavior set `build-attributes: [no-patchelf]` for the part.

After adding `build-attributes: [no-patchelf]` the snap built and ran successfully, but I'm pretty sure the patchelf step is needed for the snap to run correctly on all the machines where it should be able to.

Thanks.

Revision history for this message
Sergio Schvezov (sergiusens) wrote :

Hi there, you are no worse situation than you were before. If you are building off of xenial you should be generally ok as long as you do not use CGO as the interpreter is pretty much stable in the world we live today.

Going back to the released deb (2.35 or previous) will lead to the same result, a snap for go that wouldn't work entirely correct on classic.

That said, can I ask you to try the latest snapcraft on the `edge` channel as we have added a work around for golang base parts (it will not be bullet proof).

Alternatively, if you have linker/elf experience, I would invite you to fix this patchelf problem upstream.

Thanks for the report.

Changed in snapcraft:
status: New → Incomplete
Revision history for this message
Laurent Sesquès (sajoupa) wrote :

Hi,

My linker/elf experience is limited I'm afraid.
I've built the snap with the apt-installed snapcraft (2.40), the snap one (2.40 - 1328), and the snap --edge one (2.40.1 - 1345), and got the same result with all.

At build time (full logs at https://launchpadlibrarian.net/362677409/buildlog_snap_ubuntu_xenial_amd64_telegraf_BUILDING.txt.gz):
[...]
Staging telegraf
Priming go
Priming snap-wrappers
Priming telegraf
cannot find section
Failed to update '/build/telegraf/prime/bin/telegraf'. Retrying after stripping the .note.go.buildid from the elf file.
Snapping 'telegraf' ...

Snapped telegraf_1.5.3_amd64.snap
[...]

At run time (not sure if this is the same issue ?):

Mar 30 15:14:32 portable systemd[1]: Reloading.
Mar 30 15:14:32 portable systemd[1]: Started Service for snap application telegraf.telegraf.
Mar 30 15:14:32 portable kernel: [22773.720171] telegraf[20023]: segfault at 400318 ip 00007f5176441949 sp 00007fff554d
81a0 error 7 in ld-2.23.so[7f517643e000+26000]
Mar 30 15:14:33 portable systemd[1]: snap.telegraf.telegraf.service: Main process exited, code=dumped, status=11/SEGV
Mar 30 15:14:33 portable systemd[1]: snap.telegraf.telegraf.service: Failed with result 'core-dump'.
Mar 30 15:14:33 portable systemd[1]: snap.telegraf.telegraf.service: Service hold-off time over, scheduling restart.
Mar 30 15:14:33 portable systemd[1]: snap.telegraf.telegraf.service: Scheduled restart job, restart counter is at 1.
Mar 30 15:14:33 portable systemd[1]: Stopped Service for snap application telegraf.telegraf.
Mar 30 15:14:33 portable systemd[1]: Started Service for snap application telegraf.telegraf.
Mar 30 15:14:33 portable kernel: [22774.090611] telegraf[20063]: segfault at 400318 ip 00007fc5f1180949 sp 00007fffd908
3d10 error 7 in ld-2.23.so[7fc5f117d000+26000]
Mar 30 15:14:33 portable systemd[1]: snap.telegraf.telegraf.service: Main process exited, code=dumped, status=11/SEGV
Mar 30 15:14:33 portable systemd[1]: snap.telegraf.telegraf.service: Failed with result 'core-dump'.

Changed in snapcraft:
status: Incomplete → New
Revision history for this message
Nikolay Vinogradov (nikolay.vinogradov) wrote :
Download full text (10.4 KiB)

Same here, also tried to build Telegraf. Obviously snapcraft tries to patch binaries to re-link them to its libc, and this patching fails for Telegraf.

I prepared the test snapcraft.yaml (http://paste.ubuntu.com/p/SVtCJXx3dr/) to reproduce the issue.

The build log:

nickv@nickv-x1:~/work/microstack-lma/lma$ snapcraft
Launching a VM.
Launched: snapcraft-test-telegraf
2019-11-11T00:43:44Z INFO Waiting for restart...
core 16-2.42.1 from Canonical✓ installed
snapcraft 3.8 from Canonical✓ installed
core18 20191030 from Canonical✓ installed
Get:1 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:4 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages [545 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:6 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [182 kB]
Get:7 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages [1019 kB]
Get:8 http://security.ubuntu.com/ubuntu bionic-security/restricted amd64 Packages [9856 B]
Get:9 http://security.ubuntu.com/ubuntu bionic-security/restricted Translation-en [3480 B]
Get:10 http://archive.ubuntu.com/ubuntu bionic/main Translation-en [516 kB]
Get:11 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [617 kB]
Get:12 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [9184 B]
Get:13 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [206 kB]
Get:14 http://archive.ubuntu.com/ubuntu bionic/restricted Translation-en [3584 B]
Get:15 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [8570 kB]
Get:16 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [5476 B]
Get:17 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [2500 B]
Get:18 http://archive.ubuntu.com/ubuntu bionic/universe Translation-en [4941 kB]
Get:19 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [151 kB]
Get:20 http://archive.ubuntu.com/ubuntu bionic/multiverse Translation-en [108 kB]
Get:21 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [768 kB]
Get:22 http://archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [275 kB]
Get:23 http://archive.ubuntu.com/ubuntu bionic-updates/restricted amd64 Packages [18.6 kB]
Get:24 http://archive.ubuntu.com/ubuntu bionic-updates/restricted Translation-en [5328 B] ...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.