intel / intel/confidential-computing.sgx.sdk

tcmalloc linking errors (undefined references to __cxa_throw_bad_array_new_length and operator delete(void*, unsigned long))

Open
#60 4 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C++
Stars
2
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Hi,

I am building a simple application that utilizes tcmalloc for sgx.
My operating system is *Ubuntu 18.04.1 LTS* and I am compiling sdk (with tag sgx_1.8) successfully. (I had to include `` in `setjmp/siglongjmp.c` as described here https://github.com/intel/linux-sgx/issues/160 and also ignore some warning flags).

I am getting this linker errors for undefined delete operator and __cxa_throw_bad_array_new_length. (see below)

```
./Enclave/gperftools/gperftools-2.5/src/symbolize.o: In function `_GLOBAL__sub_I_symbolize.cc':
symbolize.cc:(.text.startup+0x105): undefined reference to `operator delete(void*, unsigned long)'
./Enclave/gperftools/gperftools-2.5/src/malloc_extension.o: In function `MallocExtension_ocall::~MallocExtension_ocall()':
malloc_extension.cc:(.text+0x146): undefined reference to `operator delete(void*, unsigned long)'
./Enclave/gperftools/gperftools-2.5/src/malloc_extension.o: In function `SysAllocator_ocall::~SysAllocator_ocall()':
malloc_extension.cc:(.text+0x216): undefined reference to `operator delete(void*, unsigned long)'
./Enclave/gperftools/gperftools-2.5/src/tcmalloc.o: In function `TCMallocImplementation_ocall::ReadHeapGrowthStackTraces()':
tcmalloc.cc:(.text._ZN28TCMallocImplementation_ocall25ReadHeapGrowthStackTracesEv[_ZN28TCMallocImplementation_ocall25ReadHeapGrowthStackTracesEv]+0x2a0): undefined reference to `__cxa_throw_bad_array_new_length'
./Enclave/gperftools/gperftools-2.5/src/tcmalloc.o: In function `TCMallocImplementation_ocall::~TCMallocImplementation_ocall()':
tcmalloc.cc:(.text._ZN28TCMallocImplementation_ocallD0Ev[_ZN28TCMallocImplementation_ocallD5Ev]+0x1d): undefined reference to `operator delete(void*, unsigned long)'
/home/dimitra/workspace/sgx-software/linux-sgx/linux/installer/bin/sgxsdk/lib64/libsgx_tcmalloc.a(libtcmalloc_minimal_la-tcmalloc.o): In function `DumpHeapGrowthStackTraces':
/home/dimitra/workspace/sgx-software/linux-sgx/sdk/gperftools/gperftools-2.5/src/tcmalloc.cc:506: undefined reference to `__cxa_throw_bad_array_new_length'
/home/dimitra/workspace/sgx-software/linux-sgx/linux/installer/bin/sgxsdk/lib64/libsgx_tcmalloc.a(libtcmalloc_minimal_la-tcmalloc.o): In function `TCMallocImplementation::~TCMallocImplementation()':
/home/dimitra/workspace/sgx-software/linux-sgx/sdk/gperftools/gperftools-2.5/src/tcmalloc.cc:567: undefined reference to `operator delete(void*, unsigned long)'
/home/dimitra/workspace/sgx-software/linux-sgx/linux/installer/bin/sgxsdk/lib64/libsgx_tcmalloc.a(libtcmalloc_minimal_internal_la-malloc_extension.o): In function `MallocExtension::~MallocExtension()':
/home/dimitra/workspace/sgx-software/linux-sgx/sdk/gperftools/gperftools-2.5/src/malloc_extension.cc:115: undefined reference to `operator delete(void*, unsigned long)'
/home/dimitra/workspace/sgx-software/linux-sgx/linux/installer/bin/sgxsdk/lib64/libsgx_tcmalloc.a(libtcmalloc_minimal_internal_la-malloc_extension.o): In function `SysAllocator::~SysAllocator()':
/home/dimitra/workspace/sgx-software/linux-sgx/sdk/gperftools/gperftools-2.5/src/malloc_extension.cc:112: undefined reference to `operator delete(void*, unsigned long)'
/home/dimitra/workspace/sgx-software/linux-sgx/linux/installer/bin/sgxsdk/lib64/libsgx_tcmalloc.a(libtcmalloc_minimal_internal_la-system-alloc.o): In function `DefaultSysAllocator::~DefaultSysAllocator()':
/home/dimitra/workspace/sgx-software/linux-sgx/sdk/gperftools/gperftools-2.5/src/system-alloc.cc:176: undefined reference to `operator delete(void*, unsigned long)'
/home/dimitra/workspace/sgx-software/linux-sgx/linux/installer/bin/sgxsdk/lib64/libsgx_tcmalloc.a(libtcmalloc_minimal_internal_la-system-alloc.o): In function `DevMemSysAllocator::~DevMemSysAllocator()':
/home/dimitra/workspace/sgx-software/linux-sgx/sdk/gperftools/gperftools-2.5/src/system-alloc.cc:169: undefined reference to `operator delete(void*, unsigned long)'
/home/dimitra/workspace/sgx-software/linux-sgx/linux/installer/bin/sgxsdk/lib64/libsgx_tcmalloc.a(libtcmalloc_minimal_internal_la-system-alloc.o):/home/dimitra/workspace/sgx-software/linux-sgx/sdk/gperftools/gperftools-2.5/src/system-alloc.cc:156: more undefined references to `operator delete(void*, unsigned long)' follow
./Enclave/gperftools/gperftools-2.5/src/stack_trace_table.o: In function `tcmalloc_ocall::StackTraceTable::ReadStackTracesAndClear()':
stack_trace_table.cc:(.text+0x592): undefined reference to `__cxa_throw_bad_array_new_length'
./Enclave/gperftools/gperftools-2.5/src/static_vars.o: In function `tcmalloc_ocall::Static::InitStaticVars()':
static_vars.cc:(.text+0x3ca): undefined reference to `operator delete(void*, unsigned long)'
collect2: error: ld returned 1 exit status
Makefile:316: recipe for target 'libenclave.so' failed
make: *** [libenclave.so] Error 1
```

I also get same errors when using the precompiled tcmalloc library from here https://01.org/intel-softwareguard-extensions/downloads/intel-sgx-linux-1.8-release.

Any idea why I am getting this error?

P.S. new and delete operators are defined in the same file (gperftools-2.5/src/libc_override_redefine.h) -- I cannot understand why the linker is complaining (let alone why it is only complaining about delete and not new operator).

Thanks,
-Dimitra

Contributor guide

Open the contributing guide

Research direction

Start with the Makefile target for libenclave.so and the linker inputs, then inspect gperftools-2.5/src/libc_override_redefine.h alongside the reported tcmalloc, malloc_extension, system-alloc, and stack_trace_table sources. Compare the build with the precompiled tcmalloc library and verify that linking completes without the reported undefined references.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.