-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
AddressSanitizer change the behaviour of fmemopen #627
Comments
The code assertion-crashes for me both with gcc & head clang: tmp/627.c:8: int main(int, char *): Assertion `f != ((void)0)' failed. gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04) |
After some research, it seems that this is an issue with symbol versionning. Prior to glibc 2.22, the implementation of fmemopen return NULL if size == 0. Since glibc 2.22, the implementation of fmemopen doesn't return NULL if size == 0. You probably have an version of glibc <2.22, so the code fail without AddressSanitizer. glibx export a versioned symbol for the new version. When compiling whithout I don't think this is the intended behavior.
|
What system are you using exactly? (glibc version? kernel version? distro?) |
Arch Linux,
|
Ah, so this is a very new system. I don't think we've played with such before. |
Yes, with ASan we use the old version. Unfortunately, that's how dlopen works (and by extension, ASan interceptors). I'd argue that you should not call fmemopen with 0 size if there are reasonably recent versions of glibc that do not support that. |
There isn't any special logic handling failure cases for fmemopen. There is, however, a symbol versioning problem. I created #628 to track it. |
fmemopen(2) is broken with address and memory sanitizer, see google/sanitizers#627 and google/sanitizers#628.
When compiling using AddressSanitizer, a call to fmemopen with a size of 0, return NULL.
Without AddressSanitizer, this works.
I made a gist with a minimal working example:
https://gist.github.com/dzamlo/676b75a21fa85ead765a
The code work fine when compiling with
gcc -o test test.c
, but fail when compilling withgcc -fsanitize=address -o test test.c
. It the same with clang.The text was updated successfully, but these errors were encountered: