Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

==6220==ERROR: AddressSanitizer failed to deallocate 0x20000 (131072) bytes at address 0x00014fb34800 #849

Closed
DaHuO opened this issue Aug 18, 2017 · 18 comments

Comments

@DaHuO
Copy link

DaHuO commented Aug 18, 2017

I'm trying to use address sanitizer in xcode debuging an iOS program. However, it crashes with the following error:

==6220==ERROR: AddressSanitizer failed to deallocate 0x20000 (131072) bytes at address 0x00014fb34800
==6220==AddressSanitizer CHECK failed: /Library/Caches/com.apple.xbs/Sources/clang_compiler_rt/clang-802.0.41/src/projects/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc:143 "(("unable to unmap" && 0)) != (0)" (0x0, 0x0)
    #0 0x105820ddf in __asan::AsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/var/containers/Bundle/Application/22D6C50C-6989-4809-A309-41F754D6FE9F/shehui.app/Frameworks/libclang_rt.asan_ios_dynamic.dylib:arm64+0x54ddf)

Warning: hit breakpoint while running function, skipping commands and conditions to prevent recursion.warning: could not execute support code to read Objective-C class data in the process. This may reduce the quality of type information available.
AddressSanitizer report breakpoint hit. Use 'thread info -s' to get extended information about the report.
(lldb) thread info -s
thread #19: tid = 0x147c85, 0x0000000105820cac libclang_rt.asan_ios_dynamic.dylib`__asan::AsanDie()

I think Address sanitizer has run for a while before it crashes, since I can see the following log in front:

2017-08-17:15:39:29:315 -ATAPI- ConfigManager.m:113  ==6220==WARNING: unexpected format specifier in printf interceptor: %@
@_@
==6220==WARNING: unexpected format specifier in printf interceptor: %@

Any idea what will cause " AddressSanitizer failed to deallocate"? Does the crash mean there is a problem in ConfigManager.m:113 ?

@ramosian-glider
Copy link
Member

ramosian-glider commented Aug 18, 2017 via email

@DaHuO
Copy link
Author

DaHuO commented Aug 19, 2017

@ramosian-glider
I'm building an iOS app with a bunch of third-party libraries. It runs well most of the time, but sometimes very rarely it crashes. Therefore I tried to debug this using the Address Sanitizer in Xcode, and I got this ERROR every time I run.

Since the app runs well most of the time, I think there should not be an invalid address to free(), otherwise it should crash every time.

@mzanini
Copy link

mzanini commented Oct 20, 2017

Hi, I ran into the same issue with code compiled on Red Hat Linux 6.7 and GCC 6.2.1.

==14657==ERROR: AddressSanitizer failed to deallocate 0x4000 (16384) bytes at address 0x629001220200
==14657==AddressSanitizer CHECK failed: ../../../../libsanitizer/sanitizer_common/sanitizer_posix.cc:131 "(("unable to unmap" && 0)) != (0)" (0x0, 0x0)
==14657==ERROR: AddressSanitizer failed to deallocate 0x4000 (16384) bytes at address 0x62900121b200
==14657==AddressSanitizer CHECK failed: ../../../../libsanitizer/sanitizer_common/sanitizer_posix.cc:131 "(("unable to unmap" && 0)) != (0)" (0x0, 0x0)
    #0 0x33b18cb2cd  (/usr/lib64/libasan.so.3+0x33b18cb2cd)
    #1 0x33b18d0f13 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/usr/lib64/libasan.so.3+0x33b18d0f13)
    #2 0x33b18dacaf  (/usr/lib64/libasan.so.3+0x33b18dacaf)
    #3 0x33b18db970  (/usr/lib64/libasan.so.3+0x33b18db970)
    #0 0x33b18cb2cd  (/usr/lib64/libasan.so.3+0x33b18cb2cd)
    #4 0x33b18ce578  (/usr/lib64/libasan.so.3+0x33b18ce578)
    #5 0x3c8ae07ae8 in start_thread (/lib64/libpthread.so.0+0x3c8ae07ae8)
    #6 0x3c8aae896c in __clone (/lib64/libc.so.6+0x3c8aae896c)

@kcc
Copy link
Contributor

kcc commented Oct 20, 2017

@mzanini we will need much more info in order to help you. At least:

  • a simple reproducer
  • does it happen with clang?
  • does it happen with -static-libasan (with gcc)

BTW, are you sure there is no bug in your code here?
Something like deallocating an invalid pointer...

@mzanini
Copy link

mzanini commented Oct 20, 2017

@kcc Yes I am sorry I was not able to figure out the root cause of the issue, I might let you know more once I will be able to find out. In the meantime, I noticed Martin Quinson here posted quite a detailed analysis and it really looks like the same issue that I am having.

@kcc
Copy link
Contributor

kcc commented Oct 20, 2017

Yea... But this is nowhere near a small easy-to-try reproducer :(

@mzanini
Copy link

mzanini commented Oct 31, 2017

In my case, I cannot compile address sanitizer statically because I am dealing with C++ libraries. I have noticed that the error happens only if I LD_PRELOAD the address sanitizer library. If I do not preload the library, no error from address sanitizer is shown. However, if I preload it, some LeakSanitizer errors are shown and at the end the error that is the title of this issue terminates the program.

@kcc
Copy link
Contributor

kcc commented Oct 31, 2017

I am not sure I understand the described problem. Please provide a minimized example.
In particular, I don't understand
"I cannot compile address sanitizer statically because I am dealing with C++ libraries."

Also note that using asan via LD_PRELOAD is not something we officially support.
It may work, and some users use it, but it's too tricky and has too many corner cases.

@yugr
Copy link

yugr commented Oct 31, 2017

Also note that using asan via LD_PRELOAD is not something we officially support.

Note that mzanini uses GCC where situation is the opposite...

@kcc
Copy link
Contributor

kcc commented Oct 31, 2017

Even in GCC, the default way is to link in a dynamic library, not to use LD_PRELOAD.
And yes, my team doesn't officially support GCC's use of dynamic linking asan.

@morehouse
Copy link
Contributor

Closing.

@mzanini: If the issue persists, please provide a minimal repro.

@std-vector
Copy link

std-vector commented Oct 24, 2018

Hi, @kcc @ramosian-glider
I suffered the same issue with a UE4 program compiled with clang 3.9 on linux.

I've been cooking a UE4 dedicated server on linux.
I enabled asan, and encountered "multiple definition of operator new/delete" error soon. UE4 provides me 4 operator new and 8 operator delete, and the log reminds me 10 errors. So, I removed these 10 operators in UE4 (2 operator delete left) to fix the conflict. Then I got an asan report which tells me some memory leak problems. I've no idea about these leak errors, cause they're part of UE4 Engine. I suspect that the 2 operator delete I kept might cause these leak errors, so I just removed them all and retried.

Unfortunately, there's no luck, it ran into this issue infinitely :

==14089==ERROR: AddressSanitizer failed to deallocate 0x32000 (204800) bytes at address 0x7faa20d59851
==14089==AddressSanitizer CHECK failed: /data/home/username/tmp/llvm-3.9.1/llvm-3.9.1.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc:143 "(("unable to unmap" && 0)) != (0)" (0     x0, 0x0)

Any help would be appreciated!

@kcc
Copy link
Contributor

kcc commented Oct 24, 2018

3.9 is way too old. Does this reproduce with the fresh clang (or at least with 7.0)?

@std-vector
Copy link

3.9 is way too old. Does this reproduce with the fresh clang (or at least with 7.0)?

The latest clang version UE4.18 supported is 5.0. I've tried clang 5.0, the same problem remains.

@kcc
Copy link
Contributor

kcc commented Oct 25, 2018

Sorry, we can't provide any support for 5.0

@vchigrin
Copy link

vchigrin commented Apr 10, 2019

@std-vector - saw the same problem with Clang 6.0 and UE 4.0 on Linux. After lot of debugging found a workaround by adding use_sigaltstack=0 to ASAN_OPTIONS.

UnrealEngine also uses sigaltstack system call, thus breaking some ASAN runtime assumptions about alternate signal stack state.

@ramosian-glider
Copy link
Member

ramosian-glider commented Apr 10, 2019 via email

kdesysadmin pushed a commit to KDE/kdevelop that referenced this issue Jul 10, 2022
Apparently LLVM's internal sigaltstack usage does not play well
together with the sanitizers, see [1]. This leads to failed tests
on our CI. Setting use_sigaltstack=0 as an ASAN_OPTION fixes this
issue, which this patch here does.

Sadly, we have to jump through some hoops to achieve this though.
On one hand, we want to extend the ASAN_OPTIONS, not overwrite it.
As such, we can't just set the ctest ENVIRONMENT property, as the
CI sets a bunch of custom flags in the ASAN_OPTIONS env var. Users
might have their own set of values there too. Once we can rely on
CMake 3.22 or newer, we might use ENVIRONMENT_MODIFICATION.

Furthermore, I could not get __asan_default_options() to work
with GCC.

So, instead for now we use some dirty hackery: We check whether the
use_sigaltstack option is set in ASAN_OPTIONS. If not, we set it
explicitly to 0 and then execve the test anew. This way we can be
sure that the environment gets picked up properly.

[1]: google/sanitizers#849
@mmomtchev
Copy link

Embedded Python also uses sigaltstack, had the same issue with it
Thanks for the heads up @vchigrin

qtprojectorg pushed a commit to qt/qttools that referenced this issue Jun 7, 2024
Due to ASan's use of sigaltstack, it can crash with deallocation
errors if instrumenting binaries that also use sigaltstack (directly
or transitively). As LLVM has its own sigaltstack, this has caused
integration failures in COIN (see related Jira issues).

This is a known issue, see e.g:
google/sanitizers#849
KDE/kdevelop@e306f3e

Modify the test binary such that it sets or extends the `ASAN_OPTIONS`
environment variable for QDoc's process environment, to avoid crash in
ASan. Promote the existing QProcessEnvironment to a static that is
shared between the `initTestCase` and `runQDocProcess` member
functions, to avoid the cost of repeatedly creating the QPE object.

Fixes: QTBUG-126116
Task-number: QTBUG-111580
Pick-to: 6.8
Change-Id: I25c7baed9ccec14aaad0c47512b58118a3a91d84
Reviewed-by: Topi Reiniö <[email protected]>
qtprojectorg pushed a commit to qt/qttools that referenced this issue Jun 7, 2024
Due to ASan's use of sigaltstack, it can crash with deallocation
errors if instrumenting binaries that also use sigaltstack (directly
or transitively). As LLVM has its own sigaltstack, this has caused
integration failures in COIN (see related Jira issues).

This is a known issue, see e.g:
google/sanitizers#849
KDE/kdevelop@e306f3e

Modify the test binary such that it sets or extends the `ASAN_OPTIONS`
environment variable for QDoc's process environment, to avoid crash in
ASan. Promote the existing QProcessEnvironment to a static that is
shared between the `initTestCase` and `runQDocProcess` member
functions, to avoid the cost of repeatedly creating the QPE object.

Fixes: QTBUG-126116
Task-number: QTBUG-111580
Change-Id: I25c7baed9ccec14aaad0c47512b58118a3a91d84
Reviewed-by: Topi Reiniö <[email protected]>
(cherry picked from commit 31835b4)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants