Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The process stops abruptly #39

Closed
azihassan opened this issue Nov 16, 2023 · 4 comments
Closed

The process stops abruptly #39

azihassan opened this issue Nov 16, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@azihassan
Copy link
Owner

Even though the code is written to gracefully handle errors, the process will sometimes silently exit without a stack trace.

@azihassan
Copy link
Owner Author

Running it with strace reveals a concerning message :

poll([{fd=10, events=POLLIN}], 1, 1000 <unfinished ...>) = ?
+++ killed by SIGPIPE +++

@azihassan
Copy link
Owner Author

A few lines above, we have this :

poll([{fd=10, events=POLLIN}], 1, 1000) = 1 ([{fd=10, revents=POLLIN}])
poll([{fd=10, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 0) = 1 ([{fd=10, revents=POLLIN|POLLRDNORM}])
read(10, "\16\370\320\212,J \16\313N\331\252~P\204\347\214\"g\377tV\241\207\303\21P\311# \364\254"..., 15649) = 1368
read(10, 0x55eaf6330e20, 14281)         = -1 EAGAIN (Resource temporarily unavailable)

10 seems to be the file descriptor of the underlying cURL socket :

poll(NULL, 0, 4)                        = 0 (Timeout)
socket(AF_INET, SOCK_STREAM, IPPROTO_TCP) = 10
setsockopt(10, SOL_TCP, TCP_NODELAY, [1], 4) = 0
fcntl(10, F_GETFL)                      = 0x2 (flags O_RDWR)
fcntl(10, F_SETFL, O_RDWR|O_NONBLOCK)   = 0
connect(10, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("105.73.187.12")}, 16) = -1 EINPROGRESS (Operation now in progress)

This would mean that Youtube closes the connection before the download is finished, or that youtube-d tries to read more data than what it's supposed to due to a range miscalculation or something like that.

@azihassan
Copy link
Owner Author

Relevant issue : googleapis/google-cloud-cpp#2654

@azihassan
Copy link
Owner Author

azihassan commented Nov 26, 2023

Capturing and ignoring sigpipe seems to do the trick. The printf message doesn't get displayed, I suspect that it gets overwritten by one of the writeln("\r"... calls. But there has been no crashes since. Instead, it goes into timeout and the retry mechanism takes it up from there. I'll test it for a few more days to make sure that it works before merging.

Edit : found one

image

@azihassan azihassan added the bug Something isn't working label Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant