Skip to content

[BUG] munmap_chunk(): invalid pointer crash when WITH_MIMALLOC=ON and Arrow uses glibc allocator #376

@liulx20

Description

@liulx20

When WITH_MIMALLOC=ON (the default), the neug process-wide malloc/free is overridden by mimalloc (MI_OVERRIDE=ON). However, Arrow is built with ARROW_MIMALLOC=OFF, so Arrow's internal memory pool uses glibc's allocator. This allocator mismatch causes munmap_chunk(): invalid pointer crashes when Arrow constructs Status::KeyError strings during its default memory pool initialization.

#0  __GI_raise (sig=6) at raise.c:50
#3  malloc_printerr (str="munmap_chunk(): invalid pointer") at malloc.c:5347
#4  munmap_chunk (p=<optimized out>) at malloc.c:2830
#5  arrow::util::StringBuilder<char const (&) [31]>() at ostream:662
#6  arrow::Status::FromArgs<char const (&) [31]>(code=KeyError) at status.h:170
#8  arrow::internal::GetEnvVar(name="ARROW_DEFAULT_MEMORY_POOL") at io_util.cc:1770
#10 arrow::(anonymous namespace)::UserSelectedBackend() at memory_pool.cc:133
#12 arrow::default_memory_pool() at memory_pool.cc:658
#16 neug::fsys::LocalFileSystem::toArrowFileSystem() at file_system.cc:52
#17 neug::function::CSVReadFunction::sniffFunc() 

MI_OVERRIDE=ON replaces malloc/free globally with mimalloc, but Arrow's internal allocator still calls glibc's free() → munmap_chunk() on memory allocated through mimalloc-overridden malloc(). The chunk metadata is incompatible, causing the abort.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

Status
In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions