Commit graph

7802 commits

Author SHA1 Message Date
TW
fc39330afe
Merge pull request #9588 from ThomasWaldmann/fix-remoterepo-1.4
remote repo fixes 1.4
2026-05-04 21:59:23 +02:00
TW
bb7bc62fe8
Merge pull request #9586 from ThomasWaldmann/fix-chunker-1.4
chunker fixes 1.4
2026-05-04 21:57:34 +02:00
TW
8cbf2596a4
Merge pull request #9575 from ThomasWaldmann/hashindex-fixes-1.4
hashindex fixes 1.4
2026-05-04 21:53:15 +02:00
TW
164e9d0cb1
Merge pull request #9587 from ThomasWaldmann/fix-lrucache-1.4
LRUCache fixes 1.4
2026-05-04 21:32:08 +02:00
TW
22049f8e8b
Merge pull request #9585 from ThomasWaldmann/fix-crypto-ll-1.4
crypto module fixes 1.4
2026-05-04 21:30:13 +02:00
Thomas Waldmann
37f66f11ab
_chunker.c: fix some bugs
- better check return value of fd.read(n) and reject if it returns more bytes than requested.
- avoid giving len<=0 to posix_fadvise(), which could drop the rest of the file from cache.
- buzhash: check for len == 0 edge case
- correctly Py_DECREF in cases of errors
- check for malloc/calloc failures
2026-05-04 21:05:05 +02:00
Thomas Waldmann
2d7d5f2482
crypto low_level: fix freeing of memory
The previous code performed allocations and buffer acquisitions before the
`try` block. If a later allocation or buffer acquisition failed, execution did
not enter the `finally` block, so resources acquired earlier in the setup path
could leak.

Move allocation and buffer acquisition into the guarded block, initialize raw
output pointers to `NULL`, and only call `PyMem_Free` or `PyBuffer_Release`
for resources that were actually acquired.
2026-05-04 20:57:00 +02:00
Thomas Waldmann
cd2f5a0648
_hashindex.c: more fixes
- avoid buckets_length integer overflow on 32bit systems via huge num_buckets
- always initialize index-> min_empty and num_empty
- correctly free memory when header validation fails.
  this is a minor issue, because borg will terminate in that case anyway.
- make it possible to lookup in compacted hashtables
- deal safely with empty index: we must use num_buckets = 1 to avoid division
  by zero and sanity check in hashindex_read.
- reinitialize upper/lower limit and min_empty after compact
- fix size_idx / fit_size / grow_size / shrink_size (mind array bounds)
- deal with growing when already at max capacity
- hashindex_resize: replace num_entries assertion, rather return error
- BaseIndex.clear: always stay in valid state
  Do not free the old index before we successfully have allocated a new one.
  This is a minor issue as the Exception raised would terminate borg anyway.
2026-05-04 20:32:13 +02:00
Thomas Waldmann
3a130ee591
extract: resolve memory leak on abandoned async requests in RemoteRepository
When a generator for get_many() or call_many() is destroyed early (for example, if a BackupError occurs during extraction and aborts fetching preloaded chunks), a GeneratorExit is raised inside call_many().

Previously, call_many() lacked a try/finally block, so it failed to mark the abandoned msgids in self.ignore_responses. When the remote server eventually sent the data, it was indefinitely cached in self.responses and self.chunkid_to_msgids, causing a memory leak.

This fix wraps the request loop in try/finally to guarantee that all pending waiting_for message IDs, as well as any unrequested preloaded chunk IDs in calls, are properly added to ignore_responses.

For example, this memory leak could be triggered when extracting files:
- by permission errors or other OSErrors with the extracted file
- if the archived file had all-zero replacement chunks or inconsistent size
2026-05-04 20:08:43 +02:00
Thomas Waldmann
32cfddc34c
LRUCache fixes
fix: resolve KeyError and memory leaks in LRUCache

- __setitem__: assign value before popping from _lru to avoid KeyError when exceeding capacity.
- clear(): clear the _lru list also to prevent stale keys causing KeyErrors during future evictions.
2026-05-04 20:08:12 +02:00
TW
b055b713af
Merge pull request #9583 from ThomasWaldmann/cpa10-1.4
use cross-platform-actions/action@v1.0.0, fixes #9565
2026-05-04 19:38:33 +02:00
Thomas Waldmann
86e6dd4207
use cross-platform-actions/action@v1.0.0, fixes #9565 2026-05-04 19:00:17 +02:00
TW
477f987372
Merge pull request #9522 from ThomasWaldmann/hashindex-fix-for-bigendian-1.4
Some checks failed
CI / lint (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Windows CI / msys2-ucrt64 (push) Has been cancelled
CI / asan_ubsan (push) Has been cancelled
CI / native_tests (push) Has been cancelled
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Has been cancelled
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Has been cancelled
CI / vm_tests (OpenBSD, false, openbsd, 7.7) (push) Has been cancelled
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Has been cancelled
hashindex: fix new checks for big endian archs, fixes #9521
2026-03-19 16:03:00 +01:00
Thomas Waldmann
7fd6df2514
hashindex: fix new checks for big endian archs, fixes #9521 2026-03-19 15:14:57 +01:00
TW
aaf397a632
Merge pull request #9511 from ThomasWaldmann/rel144
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Windows CI / msys2-ucrt64 (push) Waiting to run
Release 1.4.4
2026-03-19 09:10:48 +01:00
Thomas Waldmann
083eaa0418
update CHANGES 2026-03-18 23:56:15 +01:00
Thomas Waldmann
8ddf789ec3
add .DS_Store to .gitignore 2026-03-18 23:56:12 +01:00
Thomas Waldmann
ff5be71f73
build_usage build_man 2026-03-18 23:56:10 +01:00
TW
b3e695cc49
Merge pull request #9510 from ThomasWaldmann/new-version-selector-location-1.4
Some checks are pending
CI / lint (push) Waiting to run
CI / asan_ubsan (push) Blocked by required conditions
CI / native_tests (push) Blocked by required conditions
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Blocked by required conditions
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Blocked by required conditions
CI / vm_tests (OpenBSD, false, openbsd, 7.7) (push) Blocked by required conditions
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Blocked by required conditions
CodeQL / Analyze (push) Waiting to run
Windows CI / msys2-ucrt64 (push) Waiting to run
docs: move RTD version selector to sidebar top-left, fixes #8204
2026-03-18 23:39:00 +01:00
Thomas Waldmann
c046a154f2
docs: move RTD version selector to sidebar top-left
That way, right below the docs version number that is currently
being displayed, it is easier to find for users.

Also: hide the default readthedocs-flyout (bottom right)

Co-authored-by: Junie <junie@jetbrains.com>
2026-03-18 23:34:38 +01:00
TW
519cc99f30
Merge pull request #9505 from ThomasWaldmann/fix/borgfs-fstab-home-dir-3395
helpers: get_base_dir: avoid using incorrect HOME, fixes #3395
2026-03-18 23:12:08 +01:00
TW
65422547a1
Merge pull request #9507 from ThomasWaldmann/hashindex-fixes-1.4
hashindex: check values in read HashHeader, fixes #9485
2026-03-18 22:07:28 +01:00
TW
21353a34c5
Merge pull request #9506 from ThomasWaldmann/improve-serve-append-only-docs-1.4
Some checks are pending
CI / lint (push) Waiting to run
CI / asan_ubsan (push) Blocked by required conditions
CI / native_tests (push) Blocked by required conditions
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Blocked by required conditions
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Blocked by required conditions
CI / vm_tests (OpenBSD, false, openbsd, 7.7) (push) Blocked by required conditions
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Blocked by required conditions
CodeQL / Analyze (push) Waiting to run
Windows CI / msys2-ucrt64 (push) Waiting to run
clarify append-only != write-only, fixes #9304
2026-03-18 19:52:31 +01:00
Thomas Waldmann
9917dd8541
hashindex: check values in read HashHeader 2026-03-18 19:33:40 +01:00
Thomas Waldmann
4efaaca751
clarify append-only != write-only, fixes #9304 2026-03-18 19:11:35 +01:00
TW
f4dacad528
Merge pull request #9498 from ThomasWaldmann/hashindex-memleak-1.4
hashindex: fix memory leak, fixes #9497
2026-03-18 18:55:01 +01:00
TW
7f6226ca09
Merge pull request #9504 from ThomasWaldmann/warn-replaying-segments-1.4
warn when replaying segments, fixes #9233
2026-03-18 18:53:32 +01:00
Thomas Waldmann
77db9c114f
helpers: get_base_dir: avoid using HOME when it incorrectly points to root's home for non-root users (fstab borgfs), fixes #3395 2026-03-18 18:42:43 +01:00
Thomas Waldmann
d2bc38acaa
warn when replaying segments, fixes #9233
If the repo index is not uptodate, any borg operation might trigger replay_segments and thus even operations that are usually quick can take rather long, leaving the user wondering about what's going on.

While there is already a progress indicator in replay_segments, it is logged at INFO level and thus not visible if borg runs at the default WARNING level.
2026-03-18 18:08:01 +01:00
Thomas Waldmann
5df07b51ef
hashindex: fix memory leak, fixes #9497
Thanks to @rolandrc for finding and fixing this!

Also: set index->buckets = NULL to indicate "we are finished with this" and avoid use-after-free.
2026-03-18 17:45:54 +01:00
TW
1fbbbe3da2
Merge pull request #9496 from ThomasWaldmann/update-changes-1.4
Some checks are pending
CI / lint (push) Waiting to run
CI / asan_ubsan (push) Blocked by required conditions
CI / native_tests (push) Blocked by required conditions
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Blocked by required conditions
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Blocked by required conditions
CI / vm_tests (OpenBSD, false, openbsd, 7.7) (push) Blocked by required conditions
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Blocked by required conditions
CodeQL / Analyze (push) Waiting to run
Windows CI / msys2-ucrt64 (push) Waiting to run
update CHANGES (1.4)
2026-03-17 15:43:06 +01:00
Thomas Waldmann
d4a6542977
update CHANGES 2026-03-17 15:35:53 +01:00
TW
773bfef9a9
Merge pull request #9494 from ThomasWaldmann/fix-6204-1.4
docs: consolidate key backup info in borg key export, fixes #6204
2026-03-17 15:34:29 +01:00
Thomas Waldmann
d53ff5f175
docs: consolidate key backup info in borg key export, fixes #6204
Consolidate key backup documentation into `borg key export` and reference
it from Quickstart and FAQ to avoid duplication and inconsistency.

Clarify that while `repokey` or `authenticated` mode stores the key in the
repo, a separate backup is still recommended to protect against repository
corruption or data loss.
2026-03-17 14:33:19 +01:00
TW
3186cc4114
Merge pull request #9490 from ThomasWaldmann/fix-with-lock-test-1.4
Some checks are pending
CI / lint (push) Waiting to run
CI / asan_ubsan (push) Blocked by required conditions
CI / native_tests (push) Blocked by required conditions
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Blocked by required conditions
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Blocked by required conditions
CI / vm_tests (OpenBSD, false, openbsd, 7.7) (push) Blocked by required conditions
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Blocked by required conditions
CodeQL / Analyze (push) Waiting to run
Windows CI / msys2-ucrt64 (push) Waiting to run
fix race condition in test_with_lock, fixes #8810
2026-03-17 01:23:55 +01:00
Thomas Waldmann
c1e31b8865
fix race condition in test_with_lock, fixes #8810 2026-03-17 00:52:10 +01:00
TW
974340c58a
Merge pull request #9491 from ThomasWaldmann/trailing-sparse-windows-1.4
fix spurious sparse test fail on win32, fixes #7616
2026-03-17 00:30:19 +01:00
Thomas Waldmann
7565b410d3
fix spurious sparse test fail on win32, fixes #7616
Python's `os.truncate()` on Windows relies on `SetEndOfFile()`, which does
not initialize the extended disk space with zeroes. This means that
trailing sparse holes simply leave uninitialized garbage data at the end
of the file.

During sparse file extraction, when the very last chunk is a sparse hole,
the VDL (Valid Data Length) is not properly advanced by `os.truncate()`.
As a result, reading from the end of the file fetches random disk garbage
instead of zeroes, causing spurious test failures at boundaries (like
2MB or 8MB) depending on what was in the uninitialized disk sectors.

Fix this by tracking trailing holes and manually writing a single `b"\0"`
byte at the end of the file before truncating on Windows. Writing explicit
data forces NTFS to officially advance the VDL and securely zero-fill the
preceding hole space.

Re-enable `test_sparse_file` on Windows.
2026-03-16 22:44:42 +01:00
TW
b7659140e6
Merge pull request #9489 from ThomasWaldmann/windows-fixes-1.4
cygwin: skip ~root base dir test
2026-03-16 22:36:44 +01:00
TW
f452ad7fca
Merge pull request #9488 from ThomasWaldmann/archive-cwd-1.4
info: show cwd at the time of backup creation, fixes #6191
2026-03-16 21:58:54 +01:00
Thomas Waldmann
b1b9e781af
cygwin: skip ~root base dir test 2026-03-16 21:57:22 +01:00
TW
c5ee7fc7f1
Merge pull request #9487 from ThomasWaldmann/filter-xattrs-1.4
no_selinux -> filter_xattrs
2026-03-16 21:21:06 +01:00
Thomas Waldmann
80e60b4f6f
info: show cwd at the time of backup creation, fixes #6191
Useful if one archives relative paths. Together with the cwd
one can know the full path of the files.
2026-03-16 21:18:55 +01:00
Thomas Waldmann
de92a3dace
no_selinux -> filter_xattrs
Originally, we only wanted to get rid of selinux xattrs,
but macOS also uses some xattr keys that disturb our test results,
so we filter them also.
2026-03-16 20:35:55 +01:00
TW
289364b7d7
Merge pull request #9452 from borgbackup/backport-9449-to-1.4-maint
Some checks failed
CI / lint (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Windows CI / msys2-ucrt64 (push) Has been cancelled
CI / asan_ubsan (push) Has been cancelled
CI / native_tests (push) Has been cancelled
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Has been cancelled
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Has been cancelled
CI / vm_tests (OpenBSD, false, openbsd, 7.7) (push) Has been cancelled
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Has been cancelled
[Backport 1.4-maint] tests: fix coverage collection for daemonized borg mount (fuse/hlfuse)
2026-03-07 23:27:01 +01:00
Divyesh
5c42d34a1d tests: collect coverage from daemonized borg mount processes
Fixes #9448.

borg mount forks into a background daemon, so coverage was missing the process that actually handles the FUSE requests, leaving fuse.py and hlfuse.py at 0%.

Enable coverage patches:

    patch = ["subprocess", "_exit"]

This lets coverage follow spawned subprocesses and still record data for paths that terminate via os._exit().

(cherry picked from commit 6df608ab6b)
2026-03-07 22:24:56 +00:00
Divyesh
c7fa503565 tests: make coverage patch config work on Windows CI
(cherry picked from commit 00ab5b0f25)
2026-03-07 22:24:56 +00:00
Divyesh
164594fbe1 tests: collect coverage from daemonized borg mount processes
(cherry picked from commit 99be942448)
2026-03-07 22:24:56 +00:00
TW
0a0eed485b
Merge pull request #9426 from ThomasWaldmann/hashindex_size-64bit
Some checks failed
CI / lint (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
Windows CI / msys2-ucrt64 (push) Has been cancelled
CI / asan_ubsan (push) Has been cancelled
CI / native_tests (push) Has been cancelled
CI / vm_tests (Haiku, false, haiku, r1beta5) (push) Has been cancelled
CI / vm_tests (NetBSD, false, netbsd, 10.1) (push) Has been cancelled
CI / vm_tests (OpenBSD, false, openbsd, 7.7) (push) Has been cancelled
CI / vm_tests (borg-freebsd-14-x86_64-gh, FreeBSD, true, freebsd, 14.3) (push) Has been cancelled
hashindex_size: return int64_t, fixes #9423
2026-03-01 19:17:03 +01:00
Thomas Waldmann
f67bfc4b8b
hashindex_size: return int64_t, fixes #9423 2026-03-01 18:25:29 +01:00