Skip to content

Commit 8a38f30

Browse files
committed
mdbx: workaround MSVC C11-atomics and fix spilling internal accounting for MDBX_AVOID_MSYNC=ON.
2026-08-05 mdbx: update ChangeLog. 2026-08-05 mdbx: add comments and rename internal `sanitizer_probe_page_dangling()`. 2026-08-05 mdbx-cmake: use `CXX,C` for target-options as workaround cmake/visual-studio bugs. 2026-08-05 mdbx: fix copy&pase bugs in `sanitizer_kind_of_poison()` and `sanitizer_probe_page()`. 2026-08-05 mdbx-cmake: remove extra `/Oy` "omit frame pointers". 2026-08-05 mdbx-cmake: remove redundant `/utf-8`. 2026-08-05 mdbx-msvc: add compile-time guard for C11 atomics. 2026-08-05 mdbx-cmake: add `/experimental:c11atomics` for bad MSVC compiler to enable C11 atomics. 2026-08-05 mdbx-msvc: fixed MSVC warnings of implicit narrow-casting. 2026-08-05 mdbx-cmake: minor refine show compiler options. 2026-08-05 mdbx: fix copy&paste mistake in `key2float()`. 2026-08-04 mdbx: introduce `page_tmp_txnid_signature()` for clarity, checking and debugging. 2026-08-04 mdbx: push source page to the cursor's stash while splitting. 2026-08-04 mdbx: fix spilling/accounting for `MDBX_AVOID_MSYNC=ON`. 2026-08-03 mdbx: tracing of tmp-pages during splitting to avoid false-positive "dangling" issues. 2026-08-03 mdbx-tests: alter make-targets inside `stochastic` script. 2026-08-03 mdbx: drop minor unnecessary `if()` guard in `cursor_del()`. 2026-08-03 mdbx: refine/relax `txn_probe_dbi_cursors_stacks()`. 2026-08-03 mdbx-doc: minor clarify internal comments.
1 parent 0888b10 commit 8a38f30

17 files changed

Lines changed: 342 additions & 214 deletions

CMakeLists.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -732,10 +732,6 @@ else()
732732
message(STATUS "Use C${MDBX_C_STANDARD} for libmdbx but C++ portion is disabled")
733733
endif()
734734

735-
if(MSVC)
736-
add_compile_options("$<$<COMPILE_LANGUAGE:CXX,C>:/utf-8>")
737-
endif()
738-
739735
if(WIN32 AND CMAKE_SYSTEM_ARCH STREQUAL "x86" AND NOT MDBX_NATIVE_SEH)
740736
enable_language(ASM_MASM)
741737
add_library(mdbx_safeseh OBJECT "${MDBX_SOURCE_DIR}/windows-safeseh.asm")
@@ -754,7 +750,7 @@ macro(target_setup_options TARGET)
754750
set_target_properties(${TARGET} PROPERTIES CXX_STANDARD ${MDBX_CXX_STANDARD} CXX_STANDARD_REQUIRED ON)
755751
endif()
756752
if(MSVC AND NOT MSVC_VERSION LESS 1910)
757-
target_compile_options(${TARGET} INTERFACE "/Zc:__cplusplus")
753+
target_compile_options(${TARGET} INTERFACE "$<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>")
758754
endif()
759755
endif()
760756
if(CC_HAS_FASTMATH AND NOT (CMAKE_COMPILER_IS_CLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10))
@@ -767,15 +763,15 @@ macro(target_setup_options TARGET)
767763
target_compile_options(${TARGET} PRIVATE "-march=native")
768764
endif()
769765
if(MSVC)
766+
if(MSVC_C11_MAD_ATOMICS)
767+
target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:/experimental:c11atomics>")
768+
endif()
770769
if(MDBX_WITHOUT_MSVC_CRT)
771770
target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:/fp:fast;/fp:except-;/GS-;/Gs->")
772771
endif()
773772
if(CC_HAS_FORCE_INTERLOCKED_CALL)
774773
target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:$<$<CONFIG:Release>:/forceInterlockedFunctions->>")
775774
endif()
776-
if(CC_HAS_Oy_Omit_Frame_Pointers)
777-
target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:CXX,C>:$<$<CONFIG:Release>:/Oy>>")
778-
endif()
779775
endif()
780776
endmacro()
781777

@@ -1048,7 +1044,7 @@ if(NOT DEFINED MDBX_BUILD_TIMESTAMP)
10481044
endif()
10491045
set(MDBX_BUILD_FLAGS ${CMAKE_C_FLAGS})
10501046
if(MDBX_BUILD_CXX)
1051-
set(MDBX_BUILD_FLAGS ${CMAKE_CXX_FLAGS})
1047+
list(APPEND MDBX_BUILD_FLAGS ${CMAKE_CXX_FLAGS})
10521048
endif()
10531049

10541050
# append cmake's build-type flags and defines
@@ -1072,12 +1068,17 @@ if(defs_list)
10721068
list(APPEND MDBX_BUILD_FLAGS ${defs_list})
10731069
endif()
10741070

1075-
# get target compile options
1071+
# get target compile options & flags
10761072
get_target_property(options_list ${target4fetch} COMPILE_OPTIONS)
10771073
if(options_list)
10781074
list(APPEND MDBX_BUILD_FLAGS ${options_list})
10791075
endif()
1076+
get_target_property(options_list ${target4fetch} COMPILE_FLAGS)
1077+
if(options_list)
1078+
list(APPEND MDBX_BUILD_FLAGS ${options_list})
1079+
endif()
10801080

1081+
separate_arguments(MDBX_BUILD_FLAGS)
10811082
list(REMOVE_DUPLICATES MDBX_BUILD_FLAGS)
10821083
string(REPLACE ";" " " MDBX_BUILD_FLAGS "${MDBX_BUILD_FLAGS}")
10831084
if(CMAKE_CONFIGURATION_TYPES)

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ The supporting release of a stable branch with bug fixes.
8383

8484
- On Windows provided `mdbx_env_deleteA()` and define `mdbx_env_deleteT()` depend on the `UNICODE`.
8585

86+
- Added `/experimental:c11atomics` workaround for MSVC compiler weakness to enable C11 atomics.
87+
8688
### Fixes:
8789

8890
- Fixed the [issue](https://github.com/Mithril-mine/libmdbx/issues/361) of losing a table content after abortion the nested transaction where such table was dropped.
@@ -122,6 +124,7 @@ The supporting release of a stable branch with bug fixes.
122124
- Introduced the internal `TXN_NIPPED` flag to suspend spilling during GC processing.
123125
- Fixed tracking and invalidation of the inner part of the sibling cursors.
124126
- Reworked cursor's stack with introducing the `stash` of pages.
127+
- Fixed spilling/accounting for `MDBX_AVOID_MSYNC=ON`.
125128

126129
- C++ API:
127130
- Fixed ODR violations warnings from modern GCC while both LTO and UBSAN are enabled.
@@ -146,6 +149,8 @@ The supporting release of a stable branch with bug fixes.
146149
- Fixed running `ctest -T memcheck` by adding workaround of CTest/CMake bugs for Valgrind parameters.
147150
- Fixed/removed leftover usage of float point in `mdbx_stat` utility.
148151
- Fixed `mdbx_defrag` for `-f` option handling.
152+
- Fixed MSVC warnings of implicit narrow type-casting.
153+
- Added compile-time guard for C11 atomics to avoid wrong code generation on non-x86 platforms by MSVC.
149154
- etc...
150155

151156
--------------------------------------------------------------------------------

VERSION.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "git_describe": "v0.14.2-508-g9abf372f", "git_timestamp": "2026-08-03T15:34:28+03:00", "git_tree": "2c8fe36d9bdae185c8ee58be29afa4e2bc95b819", "git_commit": "9abf372f37ff8168ec41a900a71e041b345497b4", "semver": "0.14.2.508" }
1+
{ "git_describe": "v0.14.2-527-g6c0d0e15", "git_timestamp": "2026-08-05T17:32:59+03:00", "git_tree": "d11f6d7a1469db91ff8720f9c65ab9fc98314d6c", "git_commit": "6c0d0e15fa37d68b269a212f58bb581403afe421", "semver": "0.14.2.527" }

cmake/compiler.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,6 @@ endif()
354354

355355
if(MSVC)
356356
check_compiler_flag("/WX" CC_HAS_WERROR)
357-
check_compiler_flag("/Oy" CC_HAS_Oy_Omit_Frame_Pointers)
358357
check_compiler_flag("/fsanitize=address" CC_HAS_ASAN)
359358
check_compiler_flag("/fsanitize=undefined" CC_HAS_UBSAN)
360359
check_compiler_flag("/forceInterlockedFunctions" CC_HAS_FORCE_INTERLOCKED_CALL)
@@ -433,6 +432,9 @@ if(CMAKE_C_COMPILER_LOADED)
433432
endif()
434433
endif()
435434
endif()
435+
if(MSVC)
436+
check_c_compiler_flag("/experimental:c11atomics" MSVC_C11_MAD_ATOMICS)
437+
endif()
436438
endif()
437439

438440
# Check for LTO support by GCC

config.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* This file is part of the libmdbx amalgamated source code (v0.14.2-508-g9abf372f at 2026-08-03T15:34:28+03:00),
1+
/* This file is part of the libmdbx amalgamated source code (v0.14.2-527-g6c0d0e15 at 2026-08-05T17:32:59+03:00),
22
* it is the template for libmdbx's config.h
33
******************************************************************************/
44

mdbx-internals.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* This file is part of the libmdbx amalgamated source code (v0.14.2-508-g9abf372f at 2026-08-03T15:34:28+03:00).
1+
/* This file is part of the libmdbx amalgamated source code (v0.14.2-527-g6c0d0e15 at 2026-08-05T17:32:59+03:00).
22
*
33
* libmdbx (aka MDBX) is an extremely fast, compact, powerful, embeddedable, transactional key-value storage engine with
44
* open-source code. MDBX has a specific set of properties and capabilities, focused on creating unique lightweight
@@ -24,7 +24,7 @@
2424

2525
#define xMDBX_ALLOY 1 /* alloyed build */
2626

27-
#define MDBX_BUILD_SOURCERY bec3014f96f0c34a9c4c81b6950507a931e4251a04ad756d0ee866f57f9360d8_v0_14_2_508_g9abf372f
27+
#define MDBX_BUILD_SOURCERY d08dda1c90a1febd510b99380a13919a304eaca3bfe9bd1025bd706109f2a8f0_v0_14_2_527_g6c0d0e15
2828

2929
#define LIBMDBX_INTERNALS
3030
#define MDBX_DEPRECATED
@@ -3439,12 +3439,12 @@ MDBX_MAYBE_UNUSED static inline int log_if_error(const int err, const char *func
34393439
/* --------------------------------------------------------------------------------------------------------------- */
34403440

34413441
MDBX_MAYBE_UNUSED static inline char sanitizer_kind_of_poison(const void *addr, size_t size) {
3442-
if (ASAN_REGISON_IS_POISONED(addr, sizeof(size)))
3442+
if (ASAN_REGISON_IS_POISONED(addr, size))
34433443
return 'P';
34443444
if (mdbx_running_on_Valgrind()) {
3445-
if (!VALGRIND_CHECK_MEM_IS_ADDRESSABLE(addr, sizeof(size)))
3445+
if (VALGRIND_CHECK_MEM_IS_ADDRESSABLE(addr, size))
34463446
return 'N';
3447-
if (!VALGRIND_CHECK_MEM_IS_DEFINED(addr, sizeof(size)))
3447+
if (VALGRIND_CHECK_MEM_IS_DEFINED(addr, size))
34483448
return 'U';
34493449
}
34503450
return 0;

0 commit comments

Comments
 (0)