nim-lang / Nim

Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
https://nim-lang.org
Other
16.5k stars 1.46k forks source link

CI freebsd,openbsd broken: tests/stdlib/tssl.nim fails (high failure rate) #15713

Open timotheecour opened 3 years ago

timotheecour commented 3 years ago

/cc @euantorano since you're tracking those OS's

tests/stdlib/tssl.nim seems to fail very often since approximately oct 22 2020 for openbsd,freebsd

https://builds.sr.ht/~araq/job/326733 https://github.com/nim-lang/Nim/pull/15705

NOTINBATCH: lib/packages/docutils/rstgen.nim C
Error: execution of an external program failed: '/home/build/Nim/testament/testament --pedantic --batch:1_3 all -d:nimCoroutines'
FAILURE
+ nim c -r tools/ci_testresults.nim
Hint: used config file '/home/build/Nim/config/nim.cfg' [Conf]
Hint: used config file '/home/build/Nim/config/config.nims' [Conf]
..........................CC: stdlib_assertions.nim
CC: stdlib_io.nim
CC: stdlib_system.nim
CC: stdlib_parseutils.nim
CC: stdlib_math.nim
CC: stdlib_unicode.nim
CC: stdlib_strutils.nim
CC: stdlib_posix.nim
CC: stdlib_times.nim
CC: stdlib_os.nim
CC: stdlib_hashes.nim
CC: stdlib_tables.nim
CC: stdlib_streams.nim
CC: stdlib_lexbase.nim
CC: stdlib_parsejson.nim
CC: stdlib_json.nim
CC: stdlib_sets.nim
CC: stdlib_strformat.nim
CC: ci_testresults.nim

Hint:  [Link]
Hint: 57361 lines; 2.953s; 75.848MiB peakmem; Debug build; proj: /home/build/Nim/tools/ci_testresults.nim; out: /home/build/Nim/tools/ci_testresults [SuccessX]
Hint: /home/build/Nim/tools/ci_testresults  [Exec]
Category: stdlib
Name: tests/stdlib/tssl.nim C
Action: run
Result: reExitcodesDiffer
-------- Expected -------
exitcode: 0
--------- Given  --------
exitcode: 1

Output:
tssl.nim(134)            tssl
tssl.nim(69)             main
net.nim(1653)            send
net.nim(896)             socketError
net.nim(495)             raiseSSLError
Error: unhandled exception: error:02FFF036:system library:func(4095):Connection reset by peer: error:02FFF036:system library:func(4095):Connection reset by peer [SslError]
-------------------------

+ exit 1
euantorano commented 3 years ago

Interesting, I’ll have a look at it. I’m on holiday right now but will try get a chance to look.

On Sun, 25 Oct 2020, at 11:52, Timothee Cour wrote:

/cc @euantorano https://github.com/euantorano since you're tracking those OS's

tests/stdlib/tssl.nim seems to fail very often since approximately oct 22 2020 for openbsd,freebsd

https://builds.sr.ht/~araq/job/326733

15705 https://github.com/nim-lang/Nim/pull/15705

`NOTINBATCH: lib/packages/docutils/rstgen.nim C Error: execution of an external program failed: '/home/build/Nim/testament/testament --pedantic --batch:1_3 all -d:nimCoroutines' FAILURE

  • nim c -r tools/ci_testresults.nim Hint: used config file '/home/build/Nim/config/nim.cfg' [Conf] Hint: used config file '/home/build/Nim/config/config.nims' [Conf] ..........................CC: stdlib_assertions.nim CC: stdlib_io.nim CC: stdlib_system.nim CC: stdlib_parseutils.nim CC: stdlib_math.nim CC: stdlib_unicode.nim CC: stdlib_strutils.nim CC: stdlib_posix.nim CC: stdlib_times.nim CC: stdlib_os.nim CC: stdlib_hashes.nim CC: stdlib_tables.nim CC: stdlib_streams.nim CC: stdlib_lexbase.nim CC: stdlib_parsejson.nim CC: stdlib_json.nim CC: stdlib_sets.nim CC: stdlib_strformat.nim CC: ci_testresults.nim

Hint: [Link] Hint: 57361 lines; 2.953s; 75.848MiB peakmem; Debug build; proj: /home/build/Nim/tools/ci_testresults.nim; out: /home/build/Nim/tools/ci_testresults [SuccessX] Hint: /home/build/Nim/tools/ci_testresults [Exec] Category: stdlib Name: tests/stdlib/tssl.nim C Action: run Result: reExitcodesDiffer -------- Expected ------- exitcode: 0 --------- Given -------- exitcode: 1

Output: tssl.nim(134) tssl tssl.nim(69) main net.nim(1653) send net.nim(896) socketError net.nim(495) raiseSSLError Error: unhandled exception: error:02FFF036:system library:func(4095):Connection reset by peer: error:02FFF036:system library:func(4095):Connection reset by peer [SslError]

euantorano commented 3 years ago

I'm fairly surprised this affects both FreeBSD and OpenBSD, as FreeBSD uses OpenSSL and OpenBSD uses LibreSSL. The error indicates the connection is being shut prematurely for some reason.

omar-polo commented 2 years ago

Hello,

On OpenBSD tests/stdlib/tssl.nim hangs forever.

With @VlkrS we managed to track this to the selectSigpipe call in close* in net.nim (which was added in c619cedd7cba60d588707fbbb2905c8ac85fd12a.) The SIGPIPE is not really delivered, so the process waits forever on sigwait. The tls library doesn't matter, is just signal handling not working as expected.

How to solve this? I'm not sure. AFAIK OpenBSD doesn't have SO_NOSIGPIPE (freebsd does judging by setsockopt(2)).

My humble opinion (and i'm not a nim developer, i was just helping out updating the package on OpenBSD) is that the whole bockSigpipe stuff is a mess and should be avoided. (also, why blocking SIGPIPE in the close method but not in the other I/O methods?) Just tell people to signal(SIGPIPE, SIG_IGN) once at startup as everyone else is doing. Or maybe nim could do something more elaborate like what go does by default i.e. allowing the process to die from SIGPIPE on file descriptors 0, 1 and 2 (like any other UNIX program) but not from other file descriptors.

Hope this helps,

Cheers