Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
chickadee
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Matija Benko
chickadee
Commits
8c084f28
Commit
8c084f28
authored
Feb 18, 2019
by
Eddie Kohler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support clang 5.0-style sanitizers.
parent
a60ad34c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
19 deletions
+54
-19
k-sanitizers.cc
k-sanitizers.cc
+54
-19
No files found.
k-sanitizers.cc
View file @
8c084f28
...
...
@@ -59,13 +59,20 @@ struct type_descriptor {
struct
type_mismatch_data
{
source_location
location
;
type_descriptor
*
type
;
const
type_descriptor
*
type
;
unsigned
long
alignment
;
unsigned
char
type_check_kind
;
static
const
char
*
const
type_check_kind_names
[];
};
struct
type_mismatch_data_v1
{
source_location
location
;
const
type_descriptor
*
type
;
unsigned
char
log_alignment
;
unsigned
char
type_check_kind
;
};
const
char
*
const
type_mismatch_data
::
type_check_kind_names
[]
=
{
"load of"
,
"store to"
,
"reference binding to"
,
"member access within"
,
"member call on"
,
"constructor call on"
,
"downcast of"
,
"downcast of"
,
...
...
@@ -74,7 +81,7 @@ const char* const type_mismatch_data::type_check_kind_names[] = {
struct
type_data
{
source_location
location
;
type_descriptor
*
type
;
const
type_descriptor
*
type
;
};
using
overflow_data
=
type_data
;
using
invalid_value_data
=
type_data
;
...
...
@@ -82,14 +89,14 @@ using vla_bound_data = type_data;
struct
out_of_bounds_data
{
source_location
location
;
type_descriptor
*
array_type
;
type_descriptor
*
index_type
;
const
type_descriptor
*
array_type
;
const
type_descriptor
*
index_type
;
};
struct
shift_out_of_bounds_data
{
source_location
location
;
type_descriptor
*
lhs_type
;
type_descriptor
*
rhs_type
;
const
type_descriptor
*
lhs_type
;
const
type_descriptor
*
rhs_type
;
};
struct
nonnull_arg_data
{
...
...
@@ -175,28 +182,43 @@ void __ubsan_handle_shift_out_of_bounds(shift_out_of_bounds_data* data,
}
}
void
__ubsan_handle_type_mismatch
(
type_mismatch_data
*
data
,
unsigned
long
ptr
)
{
static
void
handle_type_mismatch
(
const
source_location
&
location
,
const
type_descriptor
*
type
,
unsigned
long
alignment
,
unsigned
char
type_check_kind
,
unsigned
long
ptr
)
{
if
(
!
ptr
)
{
error_printf
(
"!!! %s:%d: %s null pointer of type %s
\n
"
,
data
->
location
.
file
,
data
->
location
.
line
,
data
->
type_check_kind_names
[
data
->
type_check_kind
],
data
->
type
->
name
);
}
else
if
(
data
->
alignment
&&
(
ptr
&
(
data
->
alignment
-
1
))
!=
0
)
{
error_printf
(
"!!! %s:%d: %s misaligned address %p for type %s
\n
"
,
data
->
location
.
file
,
data
->
location
.
line
,
data
->
type_check_kind_names
[
data
->
type_check_kind
],
ptr
,
data
->
type
->
name
);
location
.
file
,
location
.
line
,
type_mismatch_data
::
type_check_kind_names
[
type_check_kind
],
type
->
name
);
}
else
if
(
alignment
&&
(
ptr
&
(
alignment
-
1
))
!=
0
)
{
error_printf
(
"!!! %s:%d: %s misaligned address %p for type %s
\n
"
,
location
.
file
,
location
.
line
,
type_mismatch_data
::
type_check_kind_names
[
type_check_kind
],
ptr
,
type
->
name
);
}
else
{
error_printf
(
"!!! %s:%d: %s address %p
\n
"
"!!! with insufficient space for an object with type %s
\n
"
,
data
->
location
.
file
,
data
->
location
.
line
,
data
->
type_check_kind_names
[
data
->
type_check_kind
],
ptr
,
data
->
type
->
name
);
location
.
file
,
location
.
line
,
type_mismatch_data
::
type_check_kind_names
[
type_check_kind
],
ptr
,
type
->
name
);
}
log_backtrace
(
"!!! "
);
}
void
__ubsan_handle_type_mismatch
(
type_mismatch_data
*
data
,
unsigned
long
ptr
)
{
handle_type_mismatch
(
data
->
location
,
data
->
type
,
data
->
alignment
,
data
->
type_check_kind
,
ptr
);
}
void
__ubsan_handle_type_mismatch_v1
(
type_mismatch_data_v1
*
data
,
unsigned
long
ptr
)
{
handle_type_mismatch
(
data
->
location
,
data
->
type
,
1UL
<<
data
->
log_alignment
,
data
->
type_check_kind
,
ptr
);
}
void
__ubsan_handle_out_of_bounds
(
out_of_bounds_data
*
data
,
unsigned
long
index
)
{
char
buf
[
NUMBUFSZ
];
...
...
@@ -251,6 +273,19 @@ void __ubsan_handle_nonnull_return(source_location* location) {
location
->
file
,
location
->
line
);
}
void
__ubsan_handle_pointer_overflow
(
source_location
*
location
,
uintptr_t
base
,
uintptr_t
result
)
{
if
(((
intptr_t
)
base
>=
0
)
==
((
intptr_t
)
result
>=
0
))
{
error_printf
(
"!!! %s:%d: %s of unsigned offset to %p overflowed to %p
\n
"
,
location
->
file
,
location
->
line
,
base
>
result
?
"addition"
:
"subtraction"
,
base
,
result
);
}
else
{
error_printf
(
"!!! %s:%d: pointer index expression with base %p overflowed to %p
\n
"
,
location
->
file
,
location
->
line
,
base
,
result
);
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment