src


Log

Author Commit Date CI Message
Edward Thomson 08f28ff5 2020-07-10T08:57:05 alloc: set up an allocator that fails before library init We require the library to be initialized with git_libgit2_init before it is functional. However, if a user tries to uses the library without doing so - as they might when getting started with the library for the first time - we will likely crash. This commit introduces some guard rails - now instead of having _no_ allocator by default, we'll have an allocator that always fails, and never tries to set an error message (since the thread-local state is set up by git_libgit2_init). We've modified the error retrieval function to (try to) ensure that the library has been initialized before getting the thread-local error message. (Unfortunately, we cannot determine if the thread local storage has actually been configured, this does require initialization by git_libgit2_init. But a naive attempt should be good enough for most cases.)
Edward Thomson 6c51014d 2020-07-11T14:24:17 libgit2: provide init_count of the library A function to provide the initialization count of the library; this is subject to race conditions but is useful for a naive determination as to whether the library has been initialized or not.
Tyler Ang-Wanek 20ce17f0 2020-08-06T16:24:27 Replace global storage TLS with new interface
Edward Thomson fd2d4759 2020-12-05T22:22:38 threads: git_tls_data to git_tlsdata Use a no-allocation approach to the TLS data abstraction.
Edward Thomson 42d5f110 2020-12-08T14:33:31 win32: provide macros for calling conventions Provide more clarity for Win32 calling conventions - now that we always compile to __cdecl on Win32, we'll define that as the the libgit2 calling convention. Also offer NTAPI (__stdcall) calling conventions for things that need callbacks from NTAPI code (eg fiber-local storage).
Edward Thomson 404dd024 2020-12-05T15:57:48 threads: rename thread files to thread.[ch]
Edward Thomson ab772974 2020-12-05T15:49:30 threads: give atomic functions the git_atomic prefix
Edward Thomson 37763d38 2020-12-05T15:26:59 threads: rename git_atomic to git_atomic32 Clarify the `git_atomic` type and functions now that we have a 64 bit version as well (`git_atomic64`).
Tyler Ang-Wanek 971b7187 2020-08-06T16:24:18 Implement generic TLS interface This adds a generic TLS interface for anyone to store TLS data. It is designed to work regardless of whether threading support is built into the library or not. Nobody in the library should directly interface with the data on the TLS struct, so it's been built to be opaque even in the library. Requires the allocator to be initialized before use.
Edward Thomson 9800728a 2020-12-05T16:08:34 util: move git_online_cpus into util The number of CPUs is useful information for creating a thread pool or a number of workers, but it's not really about threading directly. Evict it from the thread file
Edward Thomson fe07ef8a 2020-12-05T21:38:29 packbuilder: use git__noop on non-threaded systems Our git_packbuilder__cache_lock function returns a value; use git__noop.
Edward Thomson 8413c0f9 2020-12-05T21:32:48 util: move git__noop into the util header The git__noop function is more largely useful; move it into the util header. (And reduce the number of underscores.)
lhchavez 322c15ee 2020-08-01T18:24:41 Make the pack and mwindow implementations data-race-free This change fixes a packfile heap corruption that can happen when interacting with multiple packfiles concurrently across multiple threads. This is exacerbated by setting a lower mwindow open file limit. This change: * Renames most of the internal methods in pack.c to clearly indicate that they expect to be called with a certain lock held, making reasoning about the state of locks a bit easier. * Splits the `git_pack_file` lock in two: the one in `git_pack_file` only protects the `index_map`. The protection to `git_mwindow_file` is now in that struct. * Explicitly checks for freshness of the `git_pack_file` in `git_packfile_unpack_header`: this allows the mwindow implementation to close files whenever there is enough cache pressure, and `git_packfile_unpack_header` will reopen the packfile if needed. * After a call to `p_munmap()`, the `data` and `len` fields are poisoned with `NULL` to make use-after-frees more evident and crash rather than being open to the possibility of heap corruption. * Adds a test case to prevent this from regressing in the future. Fixes: #5591
lhchavez 4ae41f9c 2020-08-02T16:26:25 Make the odb race-free This change adds all the necessary locking to the odb to avoid races in the backends. Part of: #5592
Edward Thomson ef6de8d5 2020-11-27T14:46:38 Merge pull request #5704 from lhchavez/ssh-raw-certificate Also add the raw hostkey to `git_cert_hostkey`
lhchavez 5db304f0 2020-11-27T06:17:57 Fix the non-debug build in Groovy Gorilla (gcc 10.2) The release build has been failing with the following error: ```shell FAILED: src/CMakeFiles/git2internal.dir/hash.c.o /usr/bin/cc -DHAVE_QSORT_R_GNU -DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\" -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\" -DSHA1DC_NO_STANDARD_INCLUDES=1 -D_FILE_OFFSET_BITS=64 -Isrc -I../src -I../include -I../deps/pcre -I../deps/http-parser -D_GNU_SOURCE -fsanitize=thread -fno-optimize-sibling-calls -fno-omit-frame-pointer -Werror -Wall -Wextra -fvisibility= hidden -fPIC -Wno-documentation-deprecated-sync -Wno-missing-field-initializers -Wstrict-aliasing -Wstrict-prototypes -Wdeclaration-after-statement -Wshift-count-overflow -Wunused-const-variable -Wunused-function -Wint-conversion -Wformat -Wformat-security -Wmissing-declarations -g -D_DEBUG -O0 -std=gnu90 -MD -MT src/CMakeFiles/git2internal.dir/hash.c.o -MF s rc/CMakeFiles/git2internal.dir/hash.c.o.d -o src/CMakeFiles/git2internal.dir/hash.c.o -c ../src/hash.c ../src/hash.c: In function ‘git_hash_init’: ../src/hash.c:47:1: error: control reaches end of non-void function [-Werror=return-type] 47 | } | ^ ../src/hash.c: In function ‘git_hash_update’: ../src/hash.c:58:1: error: control reaches end of non-void function [-Werror=return-type] 58 | } | ^ ../src/hash.c: In function ‘git_hash_final’: ../src/hash.c:68:1: error: control reaches end of non-void function [-Werror=return-type] 68 | } | ^ ../src/hash.c: At top level: cc1: note: unrecognized command-line option ‘-Wno-documentation-deprecated-sync’ may have been intended to silence earlier diagnostics cc1: all warnings being treated as errors [11/533] Building C object src/CMakeFiles/git2internal.dir/odb_pack.c.o ninja: build stopped: subcommand failed. ``` The compiler _should_ be able to figure out that there is no way to reach the end of the non-void function since `GIT_ASSERT(0)` expands to either `assert()` or an unconditional `return -1;` (after doing constant folding and stuff, depending on the debug level). But it's not doing so at the moment, so let's help it.
lhchavez 29fe5f61 2020-11-22T18:25:00 Also add the raw hostkey to `git_cert_hostkey` `git_cert_x509` has the raw encoded certificate. Let's do the same for the SSH certificate for symmetry.
lhchavez f847fa7b 2020-02-16T02:00:56 midx: Support multi-pack-index files in odb_pack.c This change adds support for reading multi-pack-index files from the packfile odb backend. This also makes git_pack_file objects open their backing failes lazily in more scenarios, since the multi-pack-index can avoid having to open them in some cases (yay!). This change also refreshes the documentation found in src/odb_pack.c to match the updated code. Part of: #5399
Edward Thomson cac36006 2020-04-05T22:30:20 zstream: use GIT_ASSERT
Edward Thomson 0165e885 2020-04-05T22:29:56 worktree: use GIT_ASSERT
Edward Thomson 64e2b6ef 2020-04-05T22:28:19 vector: use GIT_ASSERT
Edward Thomson 63baed37 2020-04-05T22:23:54 tsort: remove assertion
Edward Thomson 8613133b 2020-04-05T22:21:30 tree: use GIT_ASSERT
Edward Thomson 2ab26a98 2020-04-05T22:17:41 transport: use GIT_ASSERT
Edward Thomson d42e4d5f 2020-04-05T22:16:57 transaction: use GIT_ASSERT
Edward Thomson 9083a0e6 2020-04-05T22:15:21 trace: use GIT_ASSERT
Edward Thomson e1af2e55 2020-04-05T22:15:06 tag: use GIT_ASSERT
Edward Thomson fc983542 2020-04-05T22:12:57 sysdir: use GIT_ASSERT
Edward Thomson c06e7987 2020-04-05T22:12:20 submodule: use GIT_ASSERT
Edward Thomson 203832c3 2020-11-21T23:04:04 strarray: use GIT_ASSERT
Edward Thomson 1e3c2d9c 2020-04-05T22:07:11 status: use GIT_ASSERT
Edward Thomson 9522de90 2020-04-05T22:06:25 stash: use GIT_ASSERT
Edward Thomson 9cf2c9dc 2020-04-05T22:05:40 signature: use GIT_ASSERT
Edward Thomson 42594f3f 2020-04-05T22:00:36 signature: use GIT_ASSERT
Edward Thomson ef6b12b0 2020-04-05T21:58:40 revwalk: use GIT_ASSERT
Edward Thomson 5bd139e9 2020-04-05T21:57:22 revparse: use GIT_ASSERT
Edward Thomson 055fbf6d 2020-04-05T21:55:59 revert: use GIT_ASSERT
Edward Thomson 59f46913 2020-04-05T21:55:13 reset: use GIT_ASSERT
Edward Thomson 36adde56 2020-04-05T21:17:42 repository: use GIT_ASSERT
Edward Thomson d4196c06 2020-04-05T19:42:16 remote: use GIT_ASSERT
Edward Thomson 89ee31a8 2020-04-05T19:35:19 refspec: use GIT_ASSERT
Edward Thomson 7f0cabd1 2020-04-05T19:33:22 refs: use GIT_ASSERT
Edward Thomson c6ebdb29 2020-11-22T09:43:06 win32: use GIT_ASSERT
Edward Thomson 7d75e1c7 2020-04-05T19:28:13 reflog: use GIT_ASSERT
Edward Thomson 98a4f278 2020-04-05T21:38:42 refdb_fs: use GIT_ASSERT
Edward Thomson 4f5f1127 2020-11-22T00:01:09 transports: use GIT_ASSERT
Edward Thomson 8d66d57f 2020-04-05T19:20:01 refdb: use GIT_ASSERT
Edward Thomson 690ff9cd 2020-04-05T19:17:58 rebase: use GIT_ASSERT
Edward Thomson 07a3c992 2020-11-21T23:52:39 streams: use GIT_ASSERT
Edward Thomson 00e57f64 2020-04-05T19:15:11 reader: use GIT_ASSERT
Edward Thomson 9cd6481e 2020-04-05T19:14:35 posix: use GIT_ASSERT
Edward Thomson 3ff56dae 2020-11-21T23:35:09 hash: use GIT_ASSERT
Edward Thomson 16b1a756 2020-04-05T18:33:55 path: use GIT_ASSERT
Edward Thomson 2cfa31c4 2020-04-05T18:30:07 path: remove unused git_path_topdir
Edward Thomson 1a724625 2020-04-05T18:27:51 patch: use GIT_ASSERT
Edward Thomson 4dba9303 2020-11-22T10:42:41 pack-objects: use GIT_ASSERT
Edward Thomson 7cd0bf65 2020-04-05T18:26:52 pack: use GIT_ASSERT
Edward Thomson 87d37896 2020-04-05T17:35:19 oid: use GIT_ASSERT
Edward Thomson a072a025 2020-04-05T17:34:12 odb_pack: use GIT_ASSERT
Edward Thomson 3bb9916c 2020-04-05T17:33:06 odb_mempack: use GIT_ASSERT
Edward Thomson 9d1cfb2f 2020-04-05T17:32:52 odb_loose: use GIT_ASSERT
Edward Thomson 931fd6b0 2020-04-05T17:29:13 odb: use GIT_ASSERT
Edward Thomson 4300aa4b 2020-04-05T17:24:32 object: use GIT_ASSERT
Edward Thomson 6718ad9f 2020-04-05T17:20:46 notes: use GIT_ASSERT
Edward Thomson 05816a98 2020-04-05T17:20:08 netops: use GIT_ASSERT
Edward Thomson ea7c807a 2020-04-05T17:18:46 net: use GIT_ASSERT
Edward Thomson a3e8b7cd 2020-04-05T17:18:20 mwindow: use GIT_ASSERT
Edward Thomson 69fb8979 2020-11-21T22:54:26 midx: use GIT_ASSERT
Edward Thomson f16f2927 2020-04-05T17:09:59 merge_file: use GIT_ASSERT
Edward Thomson 61f33f3e 2020-04-05T17:08:42 merge_driver: use GIT_ASSERT
Edward Thomson c59fbafd 2020-04-05T17:06:37 merge: use GIT_ASSERT
Edward Thomson 237657f4 2020-04-05T17:03:41 map: use GIT_ASSERT
Edward Thomson 23e38fd3 2020-04-05T17:02:17 mailmap: use GIT_ASSERT
Edward Thomson 79b0c8c8 2020-11-21T23:29:29 iterator: use GIT_ASSERT
Edward Thomson cd2fe662 2020-04-05T16:56:55 indexer: use GIT_ASSERT
Edward Thomson 1fa339be 2020-04-05T16:50:13 index: use GIT_ASSERT
Edward Thomson 3a6d04a3 2020-04-05T16:44:42 ignore: use GIT_ASSERT
Edward Thomson 01c64945 2020-04-05T16:43:55 hashsig: use GIT_ASSERT
Edward Thomson 253a873b 2020-04-05T16:33:54 hash: use GIT_ASSERT
Edward Thomson 03623b47 2020-04-05T16:28:03 futils: use GIT_ASSERT
Edward Thomson bc54898f 2020-04-05T16:27:30 filter: use GIT_ASSERT
Edward Thomson 33c5c513 2020-04-05T16:30:00 filebuf: use GIT_ASSERT
Edward Thomson a08bd547 2020-04-05T16:24:26 fetchhead: use GIT_ASSERT
Edward Thomson 9502f8e9 2020-04-05T19:13:07 pool: use GIT_ASSERT
Edward Thomson 4b093e75 2020-04-05T18:36:23 pathspec: use GIT_ASSERT
Edward Thomson 59565a05 2020-04-05T16:23:40 errors: use GIT_ASSERT
Edward Thomson 5d6c2f26 2020-04-05T14:59:54 diff: use GIT_ASSERT
Edward Thomson 81609902 2020-04-05T14:53:50 describe: use GIT_ASSERT
Edward Thomson 65c23e9c 2020-04-05T14:53:08 delta: use GIT_ASSERT
Edward Thomson 00974bca 2020-04-05T14:52:48 date: use GIT_ASSERT
Edward Thomson e7604da8 2020-04-05T14:51:56 config: use GIT_ASSERT
Edward Thomson 3b2153fe 2020-04-05T14:42:44 commit: use GIT_ASSERT
Edward Thomson d4384977 2020-04-05T14:38:20 clone: use GIT_ASSERT
Edward Thomson 5d8b75fa 2020-04-05T14:37:22 cherrypick: use GIT_ASSERT
Edward Thomson 266f26ed 2020-04-05T14:35:23 checkout: use GIT_ASSERT
Edward Thomson e0f3c33d 2020-04-05T11:22:19 buffer: git_buf_copy_cstr should return a value `git_buf_copy_cstr` is called with user-input, and wants to sanity-check that input. Allow it to return a value if the input was malformed in a way that we cannot cope.
Edward Thomson cb4bfbc9 2020-04-05T11:07:54 buffer: git_buf_sanitize should return a value `git_buf_sanitize` is called with user-input, and wants to sanity-check that input. Allow it to return a value if the input was malformed in a way that we cannot cope.
Edward Thomson a6dd5865 2020-04-05T10:23:20 buffer: use GIT_ASSERT
Edward Thomson 7d24070d 2020-04-05T10:14:28 branch: use GIT_ASSERT
Edward Thomson abb7a7e4 2020-04-05T10:11:34 blob: use GIT_ASSERT