Skip to content

Commit 2c08ebf

Browse files
committed
More portable fix for the qidx issue.
We still don't really understand why it's happening. As long as that init happens after the pthread_rwlock_rdlock(&aes_mt_ctx->tid_lock); line it's fine. Tentatively thinking it's a weird compiler optimization problem. Commentted in line as well. Also add a fix (from OpenSSH) to compile failures if there is no EC in openssl.
1 parent a64a047 commit 2c08ebf

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

cipher-ctr-mt-functions.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,16 @@ thread_loop(void *job)
280280
* a draining queue to become empty.
281281
*
282282
* Multiple threads may be waiting on a draining queue and awoken
283-
* when empty. The first thread to wake will mark it as filling,
283+
* when empty. qThe first thread to wake will mark it as filling,
284284
* others will move on to fill, skip, or wait on the next queue.
285+
* We init qidx here because if we do it at the top of the function
286+
* we get a warning about it possibly being clobbered. The exact reason
287+
* doesn't make a lot of sense but it has to happen after the
288+
* first pthread_rwlock_rdlock(). Might have something to do with
289+
* incorrect compiler optimizations.
285290
*/
286-
for (int qidx = 1;; qidx = (qidx + 1) % numkq) {
291+
int qidx;
292+
for (qidx = 1;; qidx = (qidx + 1) % numkq) {
287293
/* Check if I was cancelled, also checked in cond_wait */
288294
pthread_testcancel();
289295

ssh-pkcs11-client.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,7 @@ pkcs11_make_cert(const struct sshkey *priv,
457457
RSA_set_method(ret->rsa, helper->rsa_meth);
458458
if (helper->nrsa++ >= INT_MAX)
459459
fatal_f("RSA refcount error");
460+
#if defined(OPENSSL_HAS_ECC) && defined(HAVE_EC_KEY_METHOD_NEW)
460461
} else if (priv->type == KEY_ECDSA) {
461462
if ((helper = helper_by_ec(priv->ecdsa)) == NULL ||
462463
helper->fd == -1)
@@ -466,6 +467,7 @@ pkcs11_make_cert(const struct sshkey *priv,
466467
EC_KEY_set_method(ret->ecdsa, helper->ec_meth);
467468
if (helper->nec++ >= INT_MAX)
468469
fatal_f("EC refcount error");
470+
#endif
469471
} else
470472
fatal_f("unknown key type %s", sshkey_type(priv));
471473

0 commit comments

Comments
 (0)