pcloudcc-lneely/pclsync
Levi Neely 90945b8817
Fix debug build: compile error, false-positive abort, crash DB lock (#372)
* Fix debug build: compile error, false-positive abort, and crash DB lock

- psql_debug.c: add forward declaration for psql_do_prepare to fix
  conflicting-types compile error (BUILD=debug was broken entirely)

- pfs_debug.c: change pfs_debug_check_lock_order from abort to log-only;
  write paths legitimately take file lock before SQL and handle ordering
  via psql_trylock()+relock in pfs_reopen_file_for_writing — no actual
  deadlock risk, the check was a false positive

- psignal.c/h: add psignal_register_cleanup() hook mechanism; change
  panic() to use _exit(1) instead of abort() so all file descriptors are
  closed on crash, releasing SQLite WAL POSIX advisory locks immediately
  and preventing ASan from hanging the process as a zombie

- psql.c: register psql_panic_cleanup() hook to close the DB on panic
  (belt-and-suspenders alongside _exit fd cleanup)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* Fix debug psql_trylock: missing strong override left lockctr unupdated

The weak psql_trylock() stub in psql.c called plocks_trywrlock() directly
without updating lockctr. In the debug build, psql_unlock() asserts
lockctr > 0, so when trylock succeeded (lock acquired, lockctr still 0)
the assert fired with SIGABRT on write ops via pfs_inc_writeid_locked.

Add a strong psql_trylock() override in psql_debug.c that delegates to
psql_do_trylock(), which properly acquires the rwlock and updates lockctr.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Levi Neely <lkn@darkstar.example.net>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-09 20:49:09 +01:00
..
debug Fix debug build: compile error, false-positive abort, crash DB lock (#372) 2026-03-09 20:49:09 +01:00
LICENSE reorg source tree, link system mbedtls (#38) 2024-08-15 19:49:57 +02:00
paccountevents.h reorg source tree, link system mbedtls (#38) 2024-08-15 19:49:57 +02:00
papi.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
papi.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pbusinessaccount.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pbusinessaccount.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pcache.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pcache.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pcommands.h Fix #90, #109: Support 2FA when running as a daemon (#175) 2026-03-02 21:36:33 +01:00
pcompiler.h Code cleanup and readline for better CLI UX (#116) 2025-03-09 09:14:12 +01:00
pcontacts.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pcontacts.h reorg source tree, link system mbedtls (#38) 2024-08-15 19:49:57 +02:00
pcrc32c.c 102 create a psql namespace (#142) 2025-03-18 19:52:15 +01:00
pcrc32c.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pcrypto.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pcrypto.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pcryptofolder.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pcryptofolder.h access pcryptofolder directly from pclsync_lib (#125) 2025-03-09 19:58:00 +01:00
pdatabase.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
pdbg.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pdbg.h Fix pcl-0c1: make pdbg_runtime_level atomic (#343) 2026-03-03 20:08:18 +01:00
pdeflate.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pdeflate.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pdevice.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pdevice.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
pdevmon.c fix compile errors (#155) 2025-05-15 19:14:57 +02:00
pdevmon.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pdiff.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pdiff.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pdownload.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pdownload.h Code cleanup and readline for better CLI UX (#116) 2025-03-09 09:14:12 +01:00
pfile.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfile.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
pfileops.c 102 create a psql namespace (#142) 2025-03-18 19:52:15 +01:00
pfileops.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pfolder.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfoldersync.h move folder-related code from psynclib to pfolder 2025-04-18 15:23:50 +02:00
pfs.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfs.h Add lock ordering assertions in debug builds (#370) 2026-03-08 15:38:41 +01:00
pfs_internal.h Fix debug build segfault: add strong overrides for psql_lock/unlock functions (#177) 2026-03-03 07:59:30 +01:00
pfscrypto.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfscrypto.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
pfsfolder.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfsfolder.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
pfsstatic.c Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
pfsstatic.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
pfstasks.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfstasks.h Fix debug build segfault: add strong overrides for psql_lock/unlock functions (#177) 2026-03-03 07:59:30 +01:00
pfstasks_internal.h Fix debug build segfault: add strong overrides for psql_lock/unlock functions (#177) 2026-03-03 07:59:30 +01:00
pfsupload.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfsupload.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
pfsxattr.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pfsxattr.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
pintervaltree.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pintervaltree.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
plibs.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
plibs.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
plist.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
plist.h Fix typo: rename psync_list_bulder_* to psync_list_builder_* (#302) 2026-03-03 12:23:16 +01:00
plocalnotify.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
plocalnotify.h Code cleanup and readline for better CLI UX (#116) 2025-03-09 09:14:12 +01:00
plocalscan.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
plocalscan.h Code cleanup and readline for better CLI UX (#116) 2025-03-09 09:14:12 +01:00
plocks.c Add deadlock detection with timeouts (#364) 2026-03-08 11:55:25 +01:00
plocks.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pmem.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pmem.h Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pnetlibs.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pnetlibs.h 98 create a pdbg namespace (#139) 2025-03-13 20:28:09 +01:00
pnotify.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pnotify.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pp2p.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pp2p.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
ppagecache.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ppagecache.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
ppassword.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ppassword.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
ppassworddict.h reorg source tree, link system mbedtls (#38) 2024-08-15 19:49:57 +02:00
ppath.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ppath.h Musl fixes (#143) 2025-04-13 09:11:11 +02:00
ppathstatus.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ppathstatus.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pqevent.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pqevent.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
prand.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
prand.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
prpc.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
prpc.h 130 use trustworthy location for log and socket (#134) 2025-03-11 19:03:58 +01:00
prun.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
prun.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
prunthrottled.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
prunthrottled.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pscanexts.h Appease the LSP server (#73) 2024-11-26 19:36:49 +01:00
psettings.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
psettings.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
pshm.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pshm.h #64 simplify messaging and #71 deserialize failed (#88) 2025-02-25 09:46:46 +01:00
psignal.c Fix debug build: compile error, false-positive abort, crash DB lock (#372) 2026-03-09 20:49:09 +01:00
psignal.h Fix debug build: compile error, false-positive abort, crash DB lock (#372) 2026-03-09 20:49:09 +01:00
psock.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
psock.h eliminate pcompat (#92) 2025-02-28 22:47:32 +01:00
psql.c Fix debug build: compile error, false-positive abort, crash DB lock (#372) 2026-03-09 20:49:09 +01:00
psql.h Fix pcl-10w: remove IS_DEBUG conditional from psql.h (#363) 2026-03-07 21:37:21 +01:00
psql_internal.h Fix debug build segfault: add strong overrides for psql_lock/unlock functions (#177) 2026-03-03 07:59:30 +01:00
pssl.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pssl.h 98 create a pdbg namespace (#139) 2025-03-13 20:28:09 +01:00
psslcerts.h Add new pCloud SSL certificate fingerprint (#172) 2026-03-01 09:14:29 +01:00
pstatus.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pstatus.h Code cleanup and readline for better CLI UX (#116) 2025-03-09 09:14:12 +01:00
psuggest.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
psuggest.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
psyncer.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
psynclib.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
psynclib.h Fix pcl-r0j: rename psync_delete_sync_by_folderid to pfolder_delete_sync_by_id (#361) 2026-03-07 19:54:21 +01:00
psys.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
psys.h Fix pcl-ivv: remove weak attribute from debug hooks (#362) 2026-03-07 20:18:51 +01:00
ptask.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ptask.h 102 create a psql namespace (#142) 2025-03-18 19:52:15 +01:00
ptevent.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ptevent.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
ptimer.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ptimer.h 98 create a pdbg namespace (#139) 2025-03-13 20:28:09 +01:00
ptools.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
ptools.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
ptree.c 102 create a psql namespace (#142) 2025-03-18 19:52:15 +01:00
ptree.h Fix ptree_for_each_element loop termination condition (#319) 2026-03-03 15:29:44 +01:00
ptypes.h Appease the LSP server (#73) 2024-11-26 19:36:49 +01:00
publiclinks.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
publiclinks.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
pupload.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
pupload.h WIP: Decompose namespaces and other cleanup (#94) 2025-03-01 22:21:54 +01:00
putil.c Add memory accounting per subsystem (#371) 2026-03-08 21:47:22 +01:00
putil.h Increase maintainability: namespace refactors for putil, pfs, and pfs sub-modules (#176) 2026-03-02 22:51:25 +01:00
sockets.h Merge pclsync and poverlay_linux (#46) 2024-08-18 15:09:21 +02:00