From b87b660e7b94caf58c381a38dfb1c290fa7fd82d Mon Sep 17 00:00:00 2001 From: Oleg Jukovec <oleg.jukovec@tarantool.org> Date: Thu, 30 Jun 2022 16:38:07 +0300 Subject: [PATCH] Fix flaky tests on Ubuntu 22.04 It is necessary to handle OpenSSL errors very carefully. Otherwise, errors may appear in unexpected places. For example, we didn't catch an error from EVP_DigestInit_ex() and it appears sometimes in conn.go: func (c *Conn) getErrorHandler(rv C.int, errno error) func() error { errcode := C.SSL_get_error(c.ssl, rv) // <- here --- md4.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/md4.go b/md4.go index 7977af1..95d9d2d 100644 --- a/md4.go +++ b/md4.go @@ -51,8 +51,11 @@ func (s *MD4Hash) Close() { } func (s *MD4Hash) Reset() error { + runtime.LockOSThread() + defer runtime.UnlockOSThread() if C.X_EVP_DigestInit_ex(s.ctx, C.X_EVP_md4(), engineRef(s.engine)) != 1 { - return errors.New("openssl: md4: cannot init digest ctx") + return errors.New("openssl: md4: cannot init digest ctx: " + + errorFromErrorQueue().Error()) } return nil }