cloudflare / cloudflared

Cloudflare Tunnel client (formerly Argo Tunnel)
https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/tunnel-guide
Apache License 2.0
9.4k stars 836 forks source link

Segmentation fault on raspberry pi 2 model b #38

Open daniloncmayo opened 6 years ago

daniloncmayo commented 6 years ago

File downloaded from https://bin.equinox.io/c/VdrWdbjqyF/cloudflared-stable-linux-arm.tgz

pi@raspberrypi:~ $ ./cloudflared -v
Segmentation fault
pi@raspberrypi:~ $ uname -a 
Linux raspberrypi 4.14.52+ #1123 Wed Jun 27 17:05:32 BST 2018 armv6l GNU/Linux
pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 9.4 (stretch)
Release:    9.4
Codename:   stretch
pi@raspberrypi:~ $ cat /proc/cpuinfo 
processor   : 0
model name  : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS    : 697.95
Features    : half thumb fastmult vfp edsp java tls 
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xb76
CPU revision    : 7

Hardware    : BCM2835
Revision    : 000e
pi@raspberrypi:~ $ sha256sum cloudflared
b3730fd14bc7306b09eafefcef10025aca3f2e94a6059952426a5341ab6e4045  cloudflared
pi@raspberrypi:~ $ file cloudflared
cloudflared: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=adf2825c51e543d9a36dea416573b70eeaa2ac8a, not stripped
mbanders commented 5 years ago

@nolanlawson Question about when you ran the following command:

version=2018.12.1 date=$(date) GOOS=linux GOARCH=arm GOARM=6 CGO_ENABLED=1 CC=arm-linux-gnueabi-gcc go build -v "-ldflags=-X 'main.Version=${version}' -X 'main.BuildTime=${date}'" github.com/cloudflare/cloudflared/cmd/cloudflared

Does version have to be set to an available release from the following list? https://github.com/cloudflare/cloudflared/releasesj

That way it picks the right code to compile?

hobindar commented 5 years ago

@mbanders It does not need to be from that list. Both version and date are only used to populate the version information that is printed when running cloudflared version.

mbanders commented 4 years ago

@hobindar Thanks. Out of curiosity, have you tried to compile on the raspberry pi itself? Or does it just take too long? And what would be the command to compile on the raspberry pi itself?

marcelloinfoweb commented 4 years ago

Some problem raspberry pi zero W.

What Solution?

hasmar04 commented 4 years ago

@marcelloinfoweb I used the binaries from @hobindar and this fixed my problem. Just substituted his link into these instructions and haven't had any problems (except for issue #23 , but I think that is unrelated).

SnufflesC137 commented 4 years ago

Still happening pi b+

reshnm commented 4 years ago

If anyone is interested, I have created a Dockerfile for building cloudflared on my Mac. https://github.com/reshnm/cloudflared-build

You can build cloudflared by calling ./build.sh <version> e.g. ./build.sh 2019.11.3

harishvishwakarma commented 4 years ago

Still happening in Pi 2 Model B

charminULTRA commented 4 years ago

Still happening on Pi Zero W current version as of this date.

charminULTRA commented 4 years ago

What command is needed to compile using Go?

sudo apt-get install golang
export GOPATH=$HOME/go
go install github.com/cloudflare/cloudflared/cmd/cloudflared

This no longer works, it's not located there anymore.

charminULTRA commented 4 years ago

Here: https://bin.equinox.io/a/4SUTAEmvqzB/cloudflared-2018.7.2-linux-arm.tar.gz

This still works.

deggers commented 4 years ago

Some problem raspberry pi zero W.

What Solution?

https://github.com/cloudflare/cloudflared/issues/38#issuecomment-533908555 still works on my rpi zero like from him suggestest. Just fetched with wget from hobin the latest

queeup commented 4 years ago

Still happening in the pi 1B with latest version (2020.6.5)

balu100 commented 4 years ago

Still happening on Model B Rev 2

joehillen commented 4 years ago

Since Cloudflare seems to ignore this issues. I've switched to NextDNS. It works great. Highly recommend it.

TownLake commented 4 years ago

Hi from Cloudflare. We've made some improvements to packaging and DoH issues. That said, we still haven't been able to track down the cause of the issues with Raspberry Pi devices. I know it's frustrating.

We have the PiHole DoH issues on our list, but don't have an ETA yet when you could expect a fix. We'll update this thread and the related ones when we do. Thanks for the patience and feedback - apologies for the delay here.

abishekmuthian commented 4 years ago

I found that any version of cloudflared flaky on a Pi 1B, either an old build or a rebuilt recent version, in that it stops working after a while. I then tried DNSCrypt-Proxy, which also stopped working after a while. The common factor appears to be that they are both written in Go. I then tried unbound, which works and has the advantage that it's already in the Raspbian repository.

I recommend unbound as well as a remedy for issues with cloudflared on 32-bit ARM, as even if there is no segmentation fault in the natively built package, it stops working after a while. Here is a nice guide for setting it up on Pi Hole - https://bartonbytes.com/posts/configure-pi-hole-for-dns-over-tls/.

Using unbound for DNS over TLS specifically for secondary Pi Hole (as it's mostly the case for using older RPi) is especially useful as we can specify other encrypted DNS providers here as a fallback when Cloudflare goes down.

brbergami commented 3 years ago

I can confirm this issue still happens. I'm using a Zero W. Had to find a 2018 build that works. But if you diff, there's a ton of commits added (which I guess includes features and bug fixes), can't be 2 years and this still persist.

root@DietPi:~# uname -a
Linux DietPi 5.4.79+ #1373 Mon Nov 23 13:18:15 GMT 2020 armv6l GNU/Linux
root@DietPi:~# lsb_release -a
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:        10
Codename:       buster
root@DietPi:~# cat /proc/cpuinfo
processor       : 0
model name      : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 1423.06
Features        : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7

Hardware        : BCM2835
Revision        : 9000c1
Serial          : 000000001ea488ff
Model           : Raspberry Pi Zero W Rev 1.1

Working build: b2b46a483505babd15743d3743728ebf5a1b82ed8e47093a2009ae6e48c83034

yolofy commented 3 years ago

Same here:

Linux pizero1 5.4.79+ #1373 Mon Nov 23 13:18:15 GMT 2020 armv6l GNU/Linux

Architecture:        armv6l
Byte Order:          Little Endian
CPU(s):              1
On-line CPU(s) list: 0
Thread(s) per core:  1
Core(s) per socket:  1
Socket(s):           1
Vendor ID:           ARM
Model:               7
Model name:          ARM1176
Stepping:            r0p7
CPU max MHz:         1000.0000
CPU min MHz:         700.0000
BogoMIPS:            697.95
Flags:               half thumb fastmult vfp edsp java tls

model name  : ARMv6-compatible processor rev 7 (v6l)
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0xb76
CPU revision    : 7

Hardware    : BCM2835
Revision    : 9000c1
Model       : Raspberry Pi Zero W Rev 1.1
brbergami commented 3 years ago

@sssilver Is there any kind of testing for armv6 or that's blocking the ticket? I could test it for some fix, but I have no way to compile to that architecture. PM me if you need a hand testing binaries.

FridayJew commented 3 years ago

Same on rpi 1B , i use this https://hobin.ca/cloudflared/ builds for fix problem. Thanks for this!

brbergami commented 3 years ago

Same on rpi 1B , i use this https://hobin.ca/cloudflared/ builds for fix problem. Thanks for this!

Who maintains this? I mean, this is supposed to use a secure protocol to make queries, how safe is this build archive? The main page doesn't makes me feel precisely comfortable.

hobindar commented 3 years ago

Who maintains this?

That would be me.

I mean, this is supposed to use a secure protocol to make queries, how safe is this build archive?

In my opinion, it's definitely safe. I left a comment earlier in this thread about how to build it yourself. If you follow all the instructions in that comment, I believe the resulting binaries should be bit-for-bit identical, allowing you to verify that I did not do anything malicious in my builds. If you ever find they are not identical, let me know and we can investigate why.

The main page doesn't makes me feel precisely comfortable.

Haha, yeah, I should probably change that page at some point. That's just a page that I hacked together many years ago to try out viewport units, back when viewport units were a brand new thing (and while I was still a university student). I'll replace the page when I think of something worthwhile to replace it with.

CC: @brbergami

brbergami commented 3 years ago

@hobindar Thanks for clarifying. Regarding building them by myself, I would love that, but on the device seems quite overkill to clone a repo, Golang and build, and outside I tried to achieve this using a VM and Arm Arch linux, quite a big deal..

'Lil big question there: In which these builds differs from the ones we can find in here? I can see that those are model targeted. Is just pull and build or some manual tweaking is done to deal with something extra?

hobindar commented 3 years ago

Is just pull and build or some manual tweaking is done to deal with something extra?

There's no changes other than what's in that comment. It's just clone, tell go to build for ARMv6 and which cross-compiler to use, and build. No changes to source code, the binaries spat out by go, nor anything else.

FridayJew commented 3 years ago

'Lil big question there: In which these builds differs from the ones we can find in here?

these builds working on rpi 1b. Official build for rpi can be installed but not started.

brbergami commented 3 years ago

It's just clone, tell go to build for ARMv6 and which cross-compiler to use, and build.

Any nice guide to follow/recommend? Not a golang person tbh.

these builds working on rpi 1b. Official build for rpi can be installed but not started.

Will try for the sake of curiosity. Thanks!

titanicshark commented 3 years ago

Here's how to install 2018.7.2

cd ~ wget https://bin.equinox.io/a/4SUTAEmvqzB/cloudflared-2018.7.2-linux-arm.tar.gz mkdir argo-tunnel tar -xvzf cloudflared-2018.7.2-linux-arm.tar.gz -C ./argo-tunnel rm cloudflared-2018.7.2-linux-arm.tar.gz cd argo-tunnel ./cloudflared --version

cshorler commented 3 years ago

Same issue on: Raspberry Pi Model B Rev 2 (/proc/cpuinfo)

On trying to compile from source, I think the golang version is too old in Debian Buster (reading some errors) - so I compiled the golang backports dpkg source version to ensure no ABI issue on the machine as I haven't set up or tested a cross compiler yet. This took more than one attempt and several attempts for tests to pass, and they never did during the build process so I overrided to create the deb anyway and manually verified the failing tests (due to timeout). I probably should have checked if Raspbian did anything to that package prior to starting... too late!

go version go1.14 linux/arm

Then compiling cloudflared go install -work -v -buildmode=pie ./cmd/cloudflared

and I have a working executable... although I'm new to cloudflared, so I haven't really got to the stage of testing anything yet.

Did anyone else do this? Are my build settings different from the release package? can we git bisect? (once I have a cross compiler working... this is far too slow on the Pi!)

cshorler commented 3 years ago

the reason this fails is the released executable is compiled to Debian armhf standards which are incompatible with the first Pi - you can see this with readelf -A

for the current release:

pi@raspberrypi:~/Downloads $ readelf -A ./cloudflared
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "7-A"
  Tag_CPU_arch: v7
  Tag_CPU_arch_profile: Application
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-2
  Tag_FP_arch: VFPv3-D16
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_rounding: Needed
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_enum_size: int
  Tag_ABI_VFP_args: VFP registers
  Tag_CPU_unaligned_access: v6

note v7 and vfpv3, earlier Pi only have v6 and vfpv2.

here's the equivalent dump from my compilation result:

pi@raspberrypi:~/Downloads $ readelf -A /usr/local/bin/cloudflared 
Attribute Section: aeabi
File Attributes
  Tag_CPU_name: "6"
  Tag_CPU_arch: v6
  Tag_ARM_ISA_use: Yes
  Tag_THUMB_ISA_use: Thumb-1
  Tag_FP_arch: VFPv2
  Tag_ABI_PCS_wchar_t: 4
  Tag_ABI_FP_rounding: Needed
  Tag_ABI_FP_denormal: Needed
  Tag_ABI_FP_exceptions: Needed
  Tag_ABI_FP_number_model: IEEE 754
  Tag_ABI_align_needed: 8-byte
  Tag_ABI_enum_size: int
  Tag_ABI_VFP_args: VFP registers
  Tag_CPU_unaligned_access: v6
FrancisTurner commented 3 years ago

Who maintains this?

That would be me.

I mean, this is supposed to use a secure protocol to make queries, how safe is this build archive?

In my opinion, it's definitely safe. I left a comment earlier in this thread about how to build it yourself. If you follow all the instructions in that comment, I believe the resulting binaries should be bit-for-bit identical, allowing you to verify that I did not do anything malicious in my builds. If you ever find they are not identical, let me know and we can investigate why. CC: @brbergami

FWIW I have created a script that will check and update the armv6 cloudflared by scraping your page

https://gist.github.com/FrancisTurner/f8d53c40a201bc28328a0e8742d710dc

If you would like me to use a different way to get the data please ping me.

Usage is fairly obvious and it can be run in (root) cron as all the paths are fully specified - I added a documentation page https://francisturner.github.io/checkv6cfd.html

It assumes that cloudflared is in /usr/local/bin/ and if you ran cloudflared install to add it as a systemd service it will correctly restart that service with the new binary. Note that in such a case you will want to have disabled the systemd cloudflared-update service and timer because they pull from the cloudflare source and give you the dreaded segfault when they update.

IndraGunawan commented 10 months ago

looks like there is something wrong with the build on hobin.ca/cloudflared hence i created a build repository for armv6 cloudflared https://github.com/indragunawan/cloudflared-armv6 (no code changes and all flows are publicly accessible)

check here for the latest release https://github.com/IndraGunawan/cloudflared-armv6/releases/latest

hobindar commented 10 months ago

looks like there is something wrong with the build on hobin.ca/cloudflared

Sorry about that, I hadn't noticed the new builds on https://hobin.ca/cloudflared weren't being built properly.

They should all be working now. It was just a matter of updating the version of Go that is used by the build.