Skip to content

Commit ddfcc5b

Browse files
committed
Fix Linux clone crashes from leaked Iconv discovery
1 parent ef8ebea commit ddfcc5b

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

AGENTS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ $env:VXCORE_LOG_LEVEL="trace"; $env:VXCORE_LOG_FILE="C:\Temp\vxcore.log"; .\myap
132132

133133
## Build Commands
134134

135+
Keep vxcore's `find_package(Iconv REQUIRED)` **after** `add_subdirectory(third_party)`
136+
and before `src`/`tests`. Earlier discovery leaks `ICONV_FOUND` into libgit2 and
137+
enables its Unicode precomposition code on Linux, where directory iterator cleanup
138+
can call `iconv_close` on an uninitialized handle. Discovery must remain in the root
139+
scope because both vxcore and the standalone `test_simple_search_backend` use
140+
`Iconv::Iconv`. Clone and search tests cover both sides of this dependency.
141+
135142
```bash
136143
# Configure
137144
cmake -B build -DVXCORE_BUILD_TESTS=ON

CMakeLists.txt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ find_package(Threads REQUIRED)
3030
if(UNIX AND NOT APPLE)
3131
find_package(OpenSSL REQUIRED)
3232
endif()
33-
if(NOT WIN32)
34-
find_package(Iconv REQUIRED)
35-
endif()
36-
3733

3834
# MSVC: enable C++ exception unwinding (/EHsc). Without this, try/catch blocks
3935
# emit C4530 warnings AND don't actually unwind at runtime — uncaught exceptions
@@ -53,6 +49,14 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
5349
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
5450

5551
add_subdirectory(third_party)
52+
53+
# Discover Iconv after libgit2: leaking ICONV_FOUND into its configuration
54+
# enables Unicode precomposition on Linux and can close an uninitialized handle.
55+
# Keep the imported target in this scope for both src and standalone tests.
56+
if(NOT WIN32)
57+
find_package(Iconv REQUIRED)
58+
endif()
59+
5660
add_subdirectory(src)
5761

5862
if(VXCORE_BUILD_CLI)

0 commit comments

Comments
 (0)