This commit fixes a crash that occurred when swapping between Damus and other apps. When Damus enters background mode, NostrDB is closed and its resources released. When Damus re-enters foreground mode, NostrDB is reopened. However, an issue with the transaction inheritance logic caused a race condition where a side menu profile lookup would get an obsolete transaction containing pointers that have been freedwhen NostrDB was closed, causing a "use-after-free" memory error. The issue was fixed by improving the transaction inheritance logic to double-check if the "generation" counter (which auto increments when Damus closes and re-opens) matches the generation marked on the thread-specific transaction. This effectively prevents lookups from inheriting an obsolete transaction from a previous NostrDB generation. Closes: https://github.com/damus-io/damus/issues/3167 Changelog-Fixed: Fixed an issue where the app would crash when swapping between apps Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
9.7 KiB
9.7 KiB