https://bugs.kde.org/show_bug.cgi?id=393472

--- Comment #15 from Alexander Schlarb <alexander-kde@ninetailed.ninja> ---
I actually managed to consistently reproduce this crash using the following
script. This exists successfully on the rebuilt database, but crashes with the
same assertion on the original one:

```py
#!/usr/bin/python3
"""Scan through a complete LMDB database."""
import argparse
import pathlib
import sys

import lmdb


__dir__ = pathlib.Path(__file__).parent
__version__ = "0.1.0"


def main(argv=sys.argv[1:], program=sys.argv[0]):
        parser = argparse.ArgumentParser(description=__doc__,
prog=pathlib.Path(program).name)
        parser.add_argument("-V", "--version", action="version",
version="%(prog)s {0}".format(__version__))
        parser.add_argument("-n", "--no-subdir", action="store_false",
dest="subdir")
        parser.add_argument("dbpath", action="store")
        #parser.add_argument(…)

        args = parser.parse_args(argv)
        with lmdb.open(args.dbpath, subdir=args.subdir, max_dbs=100) as env:
                print(f"Scanning database: {args.dbpath}")
                dbnames = []
                try:
                        transaction = env.begin()
                        try:
                                cursor = transaction.cursor()
                                while cursor.next():
                                        dbnames.append(cursor.key())
                        finally:
                                cursor.close()
                finally:
                        transaction.abort()

                for dbname in dbnames:
                        print(f"Scanning database:
{args.dbpath}/{dbname.decode('utf-8')}")
                        try:
                                handle = env.open_db(dbname)
                                transaction = env.begin(db=handle)
                                try:
                                        cursor = transaction.cursor()
                                        while cursor.next():
                                                pass
                                finally:
                                        cursor.close()
                        finally:
                                transaction.abort()

        return 0


if __name__ == "__main__":
        sys.exit(main())
```

Running this on my rebuilt 1.8GiB database only takes about 1.2s (in CPython),
so it appears it could be used as an actual integrity scanner within Baloo to
detect whether the loaded database is reliable. Only caveat is that it
**needs** to run a in subprocess with exit status monitoring since the
assertion **cannot** be converted into some kind of error status being
returned.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to