Skip to content

Segmentation fault when building with ENABLE_OVERRIDE=1 and linking it statically #297

@mxmlnkn

Description

@mxmlnkn

I thought I had a pretty simple setup. I'm building rpmalloc with ENABLE_OVERRIDE and then link it into my program. My program does not even include rpmalloc.h or calls from rpmalloc. It only contains a simple main that returns 0. And I still get this SIGSEV error:

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x00005555555feb28 in _rpmalloc_heap_extract_new_span.part.0 ()
#0  0x00005555555feb28 in _rpmalloc_heap_extract_new_span.part.0 ()
#1  0x00005555556006f8 in rpmalloc ()
#2  0x00007ffff7e1997a in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff7fc947e in call_init (l=<optimized out>, argc=argc@entry=5, argv=argv@entry=0x7fffffffd808, env=env@entry=0x7fffffffd838)
    at ./elf/dl-init.c:70
#4  0x00007ffff7fc9568 in call_init (env=0x7fffffffd838, argv=0x7fffffffd808, argc=5, l=<optimized out>) at ./elf/dl-init.c:33
#5  _dl_init (main_map=0x7ffff7ffe2e0, argc=5, argv=0x7fffffffd808, env=0x7fffffffd838) at ./elf/dl-init.c:117
#6  0x00007ffff7fe32ea in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#7  0x0000000000000005 in ?? ()
#8  0x00007fffffffdc2d in ?? ()
#9  0x00007fffffffdc89 in ?? ()
#10 0x00007fffffffdc8c in ?? ()
#11 0x00007fffffffdc8f in ?? ()
#12 0x00007fffffffdc99 in ?? ()
#13 0x0000000000000000 in ?? ()

CMake excerpt for rpmalloc:

project(rpmalloc C)

add_library(rpmalloc STATIC)
set(RPMALLOC_HOME "${CMAKE_CURRENT_SOURCE_DIR}/external/rpmalloc/rpmalloc")
target_include_directories(rpmalloc SYSTEM INTERFACE ${RPMALLOC_HOME})
target_sources(rpmalloc PRIVATE
    ${RPMALLOC_HOME}/rpmalloc.c
    ${RPMALLOC_HOME}/rpmalloc.h
    ${RPMALLOC_HOME}/rpnew.h
)
set_target_properties(rpmalloc PROPERTIES LINKER_LANGUAGE C)
target_compile_definitions(rpmalloc PUBLIC ENABLE_OVERRIDE=1)

I'm not sure whether I'm using it wrong or whether it is a bug. Some example setups would have been helpful.

I'm making heavy use of static initialization. I'm not sure whether that might be triggering this problem. I can try to minimize the example if the backtrace doesn't ring a bell for you.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions