Comments (5)
There are some warnings about -Warray-bounds reported by both clang and
clang++, but passing -Wno-array-bounds does not fix the problem
Original comment by [email protected]
on 17 Jan 2012 at 12:24
from address-sanitizer.
$ ../../../../build/Release+Asserts/bin/clang t.c -S -emit-llvm -o t.ll -O3
$ ../../../../build/Release+Asserts/bin/clang++ t.c -S -emit-llvm -o tpp.ll -O3
============================================================
$ diff t.ll tpp.ll
5c5
< @a = common global [5 x i32] zeroinitializer, align 16
---
> @a = global [5 x i32] zeroinitializer, align 16
============================================================
$ cat t.ll
; ModuleID = 't.c'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v6
4:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.6.8"
@a = common global [5 x i32] zeroinitializer, align 16
define i32 @main() nounwind uwtable ssp {
entry:
store volatile i32 1, i32* getelementptr inbounds ([5 x i32]* @a, i64 1, i64 0), align 4, !tbaa !0
ret i32 0
}
!0 = metadata !{metadata !"int", metadata !1}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
============================================================
$ cat tpp.ll
; ModuleID = 't.c'
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v6
4:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.6.8"
@a = global [5 x i32] zeroinitializer, align 16
define i32 @main() nounwind uwtable ssp {
entry:
store volatile i32 1, i32* getelementptr inbounds ([5 x i32]* @a, i64 1, i64 0), align 4, !tbaa !0
ret i32 0
}
!0 = metadata !{metadata !"int", metadata !1}
!1 = metadata !{metadata !"omnipotent char", metadata !2}
!2 = metadata !{metadata !"Simple C/C++ TBAA", null}
Original comment by [email protected]
on 17 Jan 2012 at 12:25
from address-sanitizer.
Looks like AddressSanitizer.cpp explicitly ignores globals with "common"
linkage:
396 // Touch only those globals that will not be defined in other modules.
397 // Don't handle ODR type linkages since other modules may be built w/o
asan.
398 if (G->getLinkage() != GlobalVariable::ExternalLinkage &&
399 G->getLinkage() != GlobalVariable::PrivateLinkage &&
400 G->getLinkage() != GlobalVariable::InternalLinkage)
401 continue;
Kostya, what will break down if we add CommonLinkage here?
As per http://llvm.org/docs/LangRef.html#linkage_common:
common
"common" linkage is most similar to "weak" linkage, but they are used for
tentative definitions in C, such as "int X;" at global scope. Symbols with
"common" linkage are merged in the same way as weak symbols, and they may not
be deleted if unreferenced. common symbols may not have an explicit section,
must have a zero initializer, and may not be marked 'constant'. Functions and
aliases may not have common linkage.
Or maybe clang should not mark such global definitions as common?
Original comment by [email protected]
on 17 Jan 2012 at 12:48
from address-sanitizer.
We can not handle symbols with common linkage because such symbols
may be redefined in another file to have a different size.
% head a1.c* a2.c*
==> a1.c <==
int xxx;
==> a1.cc <==
int xxx;
==> a2.c <==
double xxx;
int main() { }
==> a2.cc <==
double xxx;
int main() { }
% clang a1.c a2.c
% clang++ a1.cc a2.cc
/tmp/a2-aqRav2.o:(.bss+0x0): multiple definition of `xxx'
/tmp/a1-7Snei5.o:(.bss+0x0): first defined here
/usr/bin/ld: Warning: size of symbol `xxx' changed from 4 in /tmp/a1-7Snei5.o
to 8 in /tmp/a2-aqRav2.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
%
Original comment by [email protected]
on 17 Jan 2012 at 6:13
- Changed state: WontFix
from address-sanitizer.
Adding Project:AddressSanitizer as part of GitHub migration.
Original comment by [email protected]
on 30 Jul 2015 at 9:12
- Added labels: ProjectAddressSanitizer
from address-sanitizer.
Related Issues (20)
- No redzone created before first global HOT 7
- Avoid remounting system partition on Android HOT 1
- Whitespace difference between asan and msan outputs HOT 4
- JNI-based app fails with shadow memory range interleaves with existing memory mapping after ASan instrumentation HOT 14
- Wrong base address calculation for stripped Android libraries HOT 4
- ASan shared runtime library on Android re-exports the entire libgcc interface HOT 2
- sigsegv in basic block tracer HOT 3
- Compiling with AddressSanitizer using gcc ≥4.9 breaks printng some variables in gdb on Linux HOT 7
- AddressSanitizer: while reporting a bug found another one. Ignoring. HOT 3
- [android] system property access from native code is going away HOT 2
- Link libasan with -z interpose on Linux HOT 3
- ASan is unable to link TLS arrays HOT 3
- pointer not owned error when calling malloc_usable_size() on array of structs with destructors HOT 4
- Support Android in asan_symbolize HOT 3
- thread_stats.malloced_by_size[class_id] overflow in asan_allocator.cc HOT 4
- Crash on ODR between instrumented and non-instrumented libraries HOT 2
- LSan doesn't work with empty suppressions list HOT 6
- Improve wild-free detection HOT 1
- Please tell us where you are moving due to Google Code shutdown HOT 3
- -fsanitize=address should probably imply -Bsymbolic HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from address-sanitizer.