[Bug 261196] databases/db5: __db_pthread_mutex_lock fails with EINVAL on armv7

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 14 Jan 2022 13:19:49 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261196

            Bug ID: 261196
           Summary: databases/db5: __db_pthread_mutex_lock fails with
                    EINVAL on armv7
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: mandree@FreeBSD.org
          Reporter: fuz@fuz.su
          Assignee: mandree@FreeBSD.org
             Flags: maintainer-feedback?(mandree@FreeBSD.org)

A build of mail/bogofilter (databases/db5 consumer) fails during the test suite
with failure cause:

FAIL: t.probe
=============

BDB2023 pthread lock failed: Invalid argument
BDB0061 PANIC: Invalid argument
BDB0060 PANIC: fatal region error detected; run recovery
bogofilter[5027]: DB_ENV->open, err: -30973, BDB0087 DB_RUNRECOVERY: Fatal
error, run database recovery
To recover, run: bogoutil -v --db-recover "./checks.4991.20220114T122654"
FAIL t.probe (exit status: 3)

This error seems to be produced by function __db_pthread_mutex_lock in
db-5.3.28/src/mutex/mut_pthread.c.  It appears that it only occurs when
building on armv7 (and possibly armv6 which I cannot test).

Unfortunately the db5 code is quite convoluted and I have not been able to
figure out what specific function has been called with an invalid argument. 
Given that databases/db5 is subject to special treatment on armv6/armv7 (see
bug #197227), this latent issue might have been hidden on other architectures.

If desired, I also volunteer to develop a patch to replace the SWP instruction
with modern exclusive loads/stores to avoid having to go through the pthreads
code path.

-- 
You are receiving this mail because:
You are the assignee for the bug.