Commit Graph

1476 Commits

Author SHA1 Message Date
paulip1792
a2c3b0f8af add option to reserve huge os pages at a specific numa node. 2021-08-10 16:30:44 +08:00
bmalrat
ee0b01c84d Fixed stats in mi_os_mem_alloc_aligned on windows when re-allocate
In the last try the previous mi_os_mem_free decrease stat and mi_win_virtual_alloc doesn't increase it
2021-08-04 17:46:58 -04:00
bmalrat
30be78d97a Fixed typo in headers 2021-08-04 17:31:48 -04:00
Daan Leijen
32c5e4774f update tests with static 2021-07-26 19:14:29 -07:00
Daan Leijen
bf19c6b3d6 Merge branch 'dev' of https://github.com/microsoft/mimalloc into dev 2021-07-26 19:10:27 -07:00
Daan Leijen
a3cf23c19f add test for #445 2021-07-26 19:10:21 -07:00
Daan
46cd125313
Merge pull request #423 from jserv/preprocessor-guard
Eliminate preprocessor warnings due to undefined "__GNUC__" with ClangCL
2021-06-30 20:58:19 -07:00
Artur Sinila
edb0b93c6f
Fix 'malloc-nomem1' test for 32-bit architectures 2021-06-29 22:38:43 +03:00
Jim Huang
c4947c8879 Use secure random generator on macOS
The implementation of arc4random_buf differs from its documentation. It
is documented as "always successful, and no return value is reserved to
indicate an error" for the sake of FreeBSD compatibility [1]. However,
the actual implementation on macOS invokes function "ccrng_generate" [2]
without validating the error cases. It might fail silently[3], which leads
to unexpected source of entropy.

The original arc4random used the RC4 a.k.a. ARC4 algorithm, and ChaCha20
based implementation was introduced in FreeBSD 12.0. Since macOS 10.12,
it was replaced with the NIST-approved AES cipher, and it may be replaced
again in the future as cryptographic techniques advance. Therefore, we
should not assume that arc4random never fails.

On the contrary, CCRandomGenerateBytes(), part of Cryptographic Services [4],
returns cryptographically strong random bits with explicit status code.
This patch properly calls CCRandomGenerateBytes() and checks the status.

[1] https://www.freebsd.org/cgi/man.cgi?query=arc4random_buf
[2] https://opensource.apple.com/source/CommonCrypto/CommonCrypto-60178.40.2/lib/CommonRandom.c.auto.html
[3] https://opensource.apple.com/source/Libc/Libc-1439.40.11/gen/FreeBSD/arc4random.c.auto.html
[4] https://developer.apple.com/documentation/security
2021-06-25 12:37:00 +08:00
Jim Huang
71b2c441bb CI: Update the macOS image to version 10.15 2021-06-25 10:09:19 +08:00
Jim Huang
4369fe4323 Eliminate preprocessor warnings due to undefined "__GNUC__" with ClangCL
When building some code against mimalloc with C inside Visual Studio
with ClangCL, the compiler complains about __GNUC__ being undefined.

Reported by Mojca Miklavec.

Close #422
2021-06-24 17:29:06 +08:00
hank
1c1571742d fix typo 2021-06-21 22:36:47 +08:00
David Carlier
a35a7d4f19 haiku biuld fix proposal, warning suppression. 2021-06-19 09:14:43 +00:00
Daan Leijen
076f815cec update readme 2021-06-17 20:19:34 -07:00
Daan Leijen
b0441da766 update readme for 1.7.2/2.0.2 2021-06-17 20:14:23 -07:00
Daan Leijen
752594e764 add test for #414 2021-06-17 19:47:41 -07:00
Daan Leijen
728be93977 fix for #414 making numa node count atomic 2021-06-17 19:38:51 -07:00
Daan Leijen
a83bca72b3 fixes for M1; disable interpose use zones; fix pedantic warnings 2021-06-17 19:15:09 -07:00
Daan Leijen
c8b5b74500 improve warnings 2021-06-07 17:51:27 -07:00
Daan Leijen
bb957fcd81 Merge branch 'dev' of https://github.com/microsoft/mimalloc into dev 2021-06-07 17:00:35 -07:00
Daan
cd633b2e2a
Merge pull request #411 from jserv/predict-alloc_size
Add branch hint for _mi_os_good_alloc_size
2021-06-07 16:55:39 -07:00
Daan Leijen
aeb62c2711 fix double quote includes 2021-06-07 16:50:31 -07:00
Daan Leijen
4ba32c3160 Revert "make all includes relative"
This reverts commit 1feb6123d9.
2021-06-07 16:47:57 -07:00
Daan Leijen
1feb6123d9 make all includes relative 2021-06-06 20:31:36 -07:00
Jim Huang
d48c93af2c Add branch hint for _mi_os_good_alloc_size
In _mi_os_good_alloc_size, overflow caused by alignment size is rare,
and this patch added the appropriate branch hint during range checks.
2021-05-31 12:01:35 +08:00
Jim Huang
0f57425f80 Distinguish SI and Binary Prefixes
SI prefixes [the decimal prefixes] refer strictly to powers of 10. They
should not be used to indicate powers of 2. e.g., one kilobit
represents 1000 bits instead of 1024 bits. IEC 60027‐2 symbols are
formed adding a "i" to the SI symbol (e.g. G + i = Gi).
2021-05-30 20:13:28 +08:00
Daan Leijen
e2c095fad2 fix installation directories on unix to use /lib, /include, /share; fix issues #399, #223, and #89 2021-05-21 15:15:50 -07:00
Daan Leijen
34172910e5 fix symlink and --prefix option with delayed CMAKE_INSTALL_PREFIX; fix issue #398 2021-05-21 13:01:11 -07:00
Daan
143cf9c3d6
Merge pull request #400 from mkurdej/redirect32
[Windows] Correctly choose 32-bit version of mimalloc-redirect{,32}.dll in CMake.
2021-05-21 12:17:33 -07:00
Daan
a732b762cc
Merge pull request #403 from ArcEarth/master
[CMake] Respect CMAKE_INSTALL_PREFIX at install time
2021-05-21 12:16:17 -07:00
Yupeng Zhang
712e7d3de0 [CMake] Respect CMAKE_INSTALL_PREFIX at install time
The standard way of cmake install to a destination folder is the following pattern:
```shell
cd <BUILD_DIR>
cmake <SRC_DIR>
cmake --build <BUILD_DIR>
cmake --install <BUILD_DIR> --prefix <INSTALL_DIR>
```
Right now, the `<INSTALL_DIR>` folder passed in cmake --install command is ignored,
and always installed into `C:/Program Files(x86)/...`, which is the default
`CMAKE_INSTALL_PREFIX` value passed at the `cmake <SRC_DIR>` call.
Thus, it is not possible to install the binaries into different folders
without rerun the cmake/build process.

The important thing here is, the cmake variable `CMAKE_INSTALL_PREFIX`
is supposed to be passed at `cmake --install` time with the `--prefix` argument.
In cmake file, `install` with relative path will use that prefix automaticlly.
And it is the best practice to not include CMAKE_INSTALL_PREFIX
in the `install(... DESTINATION )` argument:
```
In particular, there is no need to make paths absolute by prepending
CMAKE_INSTALL_PREFIX; this prefix is used by default if the DESTINATION is a relative path.
```
referenced from: https://cmake.org/cmake/help/latest/command/install.html
2021-05-10 12:01:03 -04:00
Marek Kurdej
acba250e60 [Windows] Correctly choose 32-bit version of mimalloc-redirect{,32}.dll. 2021-05-04 11:26:07 +02:00
Daan Leijen
73c339235c collect in debug mode in stress test 2021-04-28 16:12:32 -07:00
Daan
16b3329bd4
Merge pull request #396 from jserv/fix-copyright-date
Bump copyright date
2021-04-28 13:11:11 -07:00
Daan Leijen
29ea7a89ab add braces 2021-04-28 13:08:59 -07:00
Daan
6d1658123c
Merge pull request #391 from jserv/improve-align-down
Rewrite align_down with bitwise operations
2021-04-28 13:07:13 -07:00
Daan Leijen
aca46242ab update comment for aligned_alloc 2021-04-28 12:47:14 -07:00
Daan
45a8dc7f55
Merge pull request #385 from elbaro/fix/aligned-alloc
Fix aligned_alloc
2021-04-28 12:43:32 -07:00
Jim Huang
5940d3bcce Bump copyright date
Each source file has been changed according to relevant Git activities.
2021-04-24 16:35:11 +00:00
Daan
766f1f9345
Merge pull request #388 from nico-abram/patch-2
Fix typo in comment
2021-04-22 10:34:13 -07:00
Daan
f941015928
Merge pull request #384 from kdrag0n/fix-android-thread-id
Fix thread ID getter on Android ARM/AArch64
2021-04-22 10:33:53 -07:00
Daan
00ddc1b8a0
Merge pull request #389 from jserv/macos-predefined-macro
Revise the use of macOS predefined macro
2021-04-22 10:25:27 -07:00
Jim Huang
52943917ad Rewrite align_down with bitwise operations
mi_align_down_ptr was implemented with multiplication and division,
which can be converted to equivalent and deterministic bit operations.
2021-04-21 13:14:53 +00:00
Jim Huang
3402c6cc3f Revise the use of macOS predefined macro
Quoted from "Porting UNIX/Linux Applications to OS X,"[1]
* macro __MACH__ is defined if Mach system calls are supported;
* macro __APPLE__ is defined in any Apple computer.

__MACH__ is not specific to macOS since GNU/Hurd runs on a Mach-based
microkernel (gnumach) [2]. __MACH__ is defined by the compiler,
leading to potential confusions. The solution is just changing the
checked identifier (i.e. __APPLE__), so it is really used only on
macOS.

[1] https://developer.apple.com/library/archive/documentation/Porting/Conceptual/PortingUnix/compiling/compiling.html
[2] https://www.gnu.org/software/hurd/microkernel/mach/gnumach.html
2021-04-21 15:24:02 +08:00
unknown
8311cef0d1 Fix typo in comment
it -> if in mimalloc-types.h
2021-04-17 15:08:25 -03:00
elbaro
ad44f76598 commit 2021-04-11 03:09:23 +09:00
Danny Lin
ad2fa2bf6f
Fix thread ID getter on Android ARM/AArch64
Android's Bionic libc stores the thread ID in TLS slot 1 instead of 0
on 32-bit ARM and AArch64. Slot 0 contains a pointer to the ELF DTV
(Dynamic Thread Vector) instead, which is constant for each loaded DSO.

Because mimalloc uses the thread ID to determine whether operations are
thread-local or cross-thread (atomic), all threads having the same ID
causes internal data structures to get corrupted quickly when multiple
threads are using the allocator:

mimalloc: assertion failed: at "external/mimalloc/src/page.c":563, mi_page_extend_free
  assertion: "page->local_free == NULL"
mimalloc: assertion failed: at "external/mimalloc/src/page.c":74, mi_page_is_valid_init
  assertion: "page->used <= page->capacity"
mimalloc: assertion failed: at "external/mimalloc/src/page.c":100, mi_page_is_valid_init
  assertion: "page->used + free_count == page->capacity"
mimalloc: assertion failed: at "external/mimalloc/src/page.c":74, mi_page_is_valid_init
  assertion: "page->used <= page->capacity"

Add support for Android's alternate TLS layout to fix the crashes in
multi-threaded use cases.

Fixes #376.
2021-04-07 01:59:47 -07:00
Daan
b19da8e362
update readme for 1.7.1 and 2.0.1 2021-04-06 11:05:43 -07:00
Daan Leijen
985f313b35 bump version to 1.7.1 2021-04-06 10:56:26 -07:00
Daan Leijen
5f596056c9 use 2-6TiB area for hints to accommodate pre-windows8 better 2021-02-24 15:49:43 -08:00