Opened 5 years ago

Closed 3 years ago

#12182 closed bug (fixed)

Interrupted system call messages / read errors during peak network traffic

Reported by: kallisti5 Owned by: nobody
Priority: normal Milestone: R1/beta1
Component: Kits/Network Kit Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

Downloading a large file at a high rate with wget results in "Interrupted system call" messages.

Example:

wget https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.1.tar.xz

(screenshot attached)

Test: hrev49332, x86_64

Attachments (1)

interrupted.png (111.4 KB ) - added by kallisti5 5 years ago.

Download all attachments as: .zip

Change History (13)

by kallisti5, 5 years ago

Attachment: interrupted.png added

comment:1 by kallisti5, 5 years ago

I also see the following messages in syslog with network traffic:

KERN: thread XXX tried to acquire kernel semaphore 0.
KERN: thread XXX tried to release kernel semaphore.

comment:2 by waddlesplash, 5 years ago

Semaphore issues should've been fixed by hrev49333. Possibly related to #10747?

comment:3 by pulkomandy, 5 years ago

"Interrupted system call" is not a bug, but a feature. When a thread gets a signal, whatever syscall it is waiting on returns immediately with error EINTR and must be restarted. This makes it possible to ctrl+C a thread while it is blocked on a read(), for example.

It's possible to configure the OS to automatically restart the syscall in that case (SA_RESTART), so the apps don't have to bother with managing EINTR.

It looks like wget is not properly configured on Haiku to set this as it wants. Maybe there is some legacy BeOS code still enabled in the wget port? I don't think there are any problems on Haiku side, however.

comment:4 by kallisti5, 5 years ago

it seems like pkgman is also giving "Interrupted system call" messages... doesn't it use libcurl?

comment:5 by pulkomandy, 5 years ago

Yes, it does.

strace output would help to know which syscalls are interrupted and why?

comment:6 by kallisti5, 4 years ago

Interestingly I see this same issue with one core (SMP disabled due to other issues) every time I "resize the terminal window"

----------------------------------------------------------------------
media-video::ffmpeg-3.1.1
        /Code/haikuports/media-video/ffmpeg/ffmpeg-3.1.1.recipe
----------------------------------------------------------------------

Downloading: https://ffmpeg.org/releases/ffmpeg-3.1.1.tar.bz2 ...
--2016-07-04 21:57:44--  https://ffmpeg.org/releases/ffmpeg-3.1.1.tar.bz2
Resolving ffmpeg.org... 178.63.43.86
Connecting to ffmpeg.org|178.63.43.86|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9327512 (8.9M) [application/x-bzip2]
Saving to: ‘/Code/haikuports/media-video/ffmpeg/download/ffmpeg-3.1.1.tar.bz2’

/Code/haikuports/media-video/ffmp  29%[=================>                                            ]   2.62M   449KB/s    in 6.2s    

2016-07-04 21:57:50 (432 KB/s) - Read error at byte 2752512/9327512 (Interrupted system call). Retrying.

--2016-07-04 21:57:51--  (try: 2)  https://ffmpeg.org/releases/ffmpeg-3.1.1.tar.bz2
Connecting to ffmpeg.org|178.63.43.86|:443... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 9327512 (8.9M), 6575000 (6.3M) remaining [application/x-bzip2]
Saving to: ‘/Code/haikuports/media-video/ffmpeg/download/ffmpeg-3.1.1.tar.bz2’

/Code/haikuports/media-video/ffmpeg/downloa  45%[++++++++++++++++++++++++++=============>                                                 ]   4.03M   421KB/s    in 3.4s    

2016-07-04 21:57:55 (421 KB/s) - Read error at byte 4227072/9327512 (Interrupted system call). Retrying.

--2016-07-04 21:57:57--  (try: 3)  https://ffmpeg.org/releases/ffmpeg-3.1.1.tar.bz2
Connecting to ffmpeg.org|178.63.43.86|:443... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 9327512 (8.9M), 5100440 (4.9M) remaining [application/x-bzip2]
Saving to: ‘/Code/haikuports/media-video/ffmpeg/download/ffmpeg-3.1.1.tar.bz2’

/Code/haikuports/media-video/ffmpeg/download 100%[+++++++++++++++++++++++++++++++++++++++++==================================================>]   8.89M   426KB/s    in 12s     

2016-07-04 21:58:10 (421 KB/s) - ‘/Code/haikuports/media-video/ffmpeg/download/ffmpeg-3.1.1.tar.bz2’ saved [9327512/9327512]
"

Every time that error is seen, i've resized the terminal window :-|

comment:7 by pulkomandy, 4 years ago

This is a feature: resizing a terminal window (also in xterm) sends the SIGWINCH signal ("window changed"). This allows ncurses apps to adjust their size to the terminal when it is resized.

wget uses SIGWINCH to resize its progress bar (see https://github.com/juaristi/wget/blob/master/src/progress.c).

We should be using https://github.com/cooljeanius/wget/blob/master/gnulib/lib/safe-read.c which protects against this by using IS_EINTR (not sure where that comes from).

Sounds like a bug in how we configure and build wget, and nothing wrong on Haiku side?

comment:8 by axeld, 4 years ago

It could be a bug in how we build wget, but it may also be a bug on the Haiku side -- that's something someone should look into :-)

BTW IS_EINTR comes from the same source file, just a couple of lines above (line 35ff).

comment:9 by axeld, 4 years ago

Owner: changed from axeld to nobody
Status: newassigned

comment:10 by pulkomandy, 4 years ago

I see that this only happens with SSL (https) downloads. So I think the problem is in openssl, which is used by both wget and curl.

wget does check for EINTR from OpenSSL: https://github.com/jnothman/wget/blob/master/src/openssl.c#L269 (OpenSSL just forwards the error and does nothing special).

comment:11 by pulkomandy, 3 years ago

I'm still tracking this down...

wget properly manages this in https://github.com/greearb/ct-wget/blob/master/src/openssl.c#L360

However, our OpenSSL does not behave as expected, it gives an SSL_WANT_READ instead of an SSL_ERROR_SYSCALL and we jump out of the loop. Digging into OpenSSL sources next...

comment:12 by pulkomandy, 3 years ago

Resolution: fixed
Status: assignedclosed
Note: See TracTickets for help on using tickets.