Closed
Description
I did this
- create a service file named
curl.service
in/etc/systemd/system
[Unit]
Description=curl dynamicuser test
[Service]
Type=simple
ExecStart=/usr/bin/curl -vvv ipinfo.io/ip
DynamicUser=yes
systemctl start curl.service
results in (journalctl
):
Nov 12 17:44:06 raspi-pihole2 systemd[1]: Started curl dynamicuser test.
Nov 12 17:44:06 raspi-pihole2 curl[25517]: curl: (27) Out of memory
Nov 12 17:44:06 raspi-pihole2 systemd[1]: curl.service: Main process exited, code=exited, status=27/n/a
Nov 12 17:44:06 raspi-pihole2 systemd[1]: curl.service: Failed with result 'exit-code'.
I expected the following
curl works without problems, since this example works on x64 (Archlinux).
curl/libcurl version
curl 7.64.0 (arm-unknown-linux-gnueabihf) libcurl/7.64.0 OpenSSL/1.1.1d zlib/1.2.11 libidn2/2.0.5 libpsl/0.20.2 (+libidn2/2.0.5) libssh2/1.8.0 nghttp2/1.36.0 librtmp/2.3
Release-Date: 2019-02-06
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IDN IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets HTTPS-proxy PSL
operating system
Linux raspi-pihole2 5.4.72-v7l+ #1356 SMP Thu Oct 22 13:57:51 BST 2020 armv7l GNU/Linux
Activity
divinity76 commentedon Nov 12, 2020
what do you get on your
potatoraspi system withExecStart=/usr/bin/free
?and what about
ExecStart=/usr/bin/strace /usr/bin/curl -vvv ipinfo.io/ip
?bjoe2k4 commentedon Nov 12, 2020
divinity76 commentedon Nov 12, 2020
i'm confused, hopefully someone else will come along and be less confused than me (i'm just a random passer-by, i'm not a curl dev or anything and i have no idea what im doing)
hmm that stack trace is curious, i don't really see any ENOMEM/ENOBUFS/ENOSPC or anything that screams
malloc failed
, i wonder what thatis about though..
and this request looks like complete bogus, "\x63" looks like a completely bogus memory location in
but getrandom didn't return EFAULT, odd.. (edit: maybe strace got confused and thought it was a char* string and showed us "the content of the string" instead of the actual memory address? i guess it's possible that's what happened)
does the same thing happen if you compile this code as
gcc foo.c -lcurl
and run it asExecStart=/home/whatever/a.out
? and does it still happen if you comment out theret = curl_easy_perform(hnd);
line? it would be interesting to see exactly which line you have to make an earlyreturn 0;
to stop it from happeningbjoe2k4 commentedon Nov 12, 2020
Thanks for looking into this. I am as puzzled as you are...
This code compiles fine and executes without error even when started via the service file.
To add some more confusion, i'm seeing the same error happening on multiple Raspberry Pi 4 (both 2GB and 4GB version), however, on a Pi3B (same OS, same systemd and curl versions) the error does not occur.
bjoe2k4 commentedon Nov 12, 2020
This is the working trace on the Pi3B:
divinity76 commentedon Nov 12, 2020
suggests it might be a curl (the cli program curl) problem rather than a libcurl problem (alebit CURLE_OUT_OF_MEMORY sounds like a LIBcurl thing, idk)
on the system where it crash, if you open a shell and just run
(PS: on some netcats like the GNU netcat the syntax is
nc -l -p 9999
and in some other netcats like OpenBSD netcat it'snc -l 9999
, and super annoyingly some linux distros use GNU netcat and some linux distros use OpenBSD netcat x.x i have no idea which netcat your distro use, but i think GNU netcat is the more common one)then run with systemd
does it still crash?
also is -vvv required for it to crash, or is vvv irrelevant for crashing?
bjoe2k4 commentedon Nov 12, 2020
irrelevant, i was just hoping to get more info.
yes
Actually I've figured out what the problem was by compiling v7.73.0 from here. The latest version complains:
When adding
to the service file everything works, even the old version in RaspberryOS!
Is there a need for the home directory to be present? Can that be turned off?
single_transfer: only warn if not finding the home dir
bagder commentedon Nov 12, 2020
My proposed fix is in #6201 as not finding the home dir should not be a reason to error out like that!
4 remaining items