Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
a1227e08
Commit
a1227e08
authored
Aug 25, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some simple scripts that can aid with double-free investigations
parent
ef853774
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
11 deletions
+72
-11
src/Makefile
src/Makefile
+1
-0
src/gc/gc_alloc.cpp
src/gc/gc_alloc.cpp
+21
-11
tools/process_malloc_trace.py
tools/process_malloc_trace.py
+22
-0
tools/process_mtrace_trace.py
tools/process_mtrace_trace.py
+28
-0
No files found.
src/Makefile
View file @
a1227e08
...
...
@@ -787,6 +787,7 @@ perf_%: perf_release_%
@
true
$(call
make_target,_dbg)
$(call
make_target,_debug)
$(call
make_target,_release)
$(call
make_target,_grwl)
$(call
make_target,_grwl_dbg)
...
...
src/gc/gc_alloc.cpp
View file @
a1227e08
...
...
@@ -45,19 +45,29 @@ extern "C" void gc_compat_free(void* ptr) {
gc_free
(
ptr
);
}
int
nallocs
=
0
;
bool
recursive
=
false
;
// We may need to hook malloc as well:
// We may need to hook malloc as well. For now, these definitions serve
// as a reference on how to do that, and also can help with debugging malloc
// usage issues.
#if 0
extern "C" void* malloc(size_t sz) {
static void *(*libc_malloc)(size_t) = (void* (*)(size_t))dlsym(RTLD_NEXT, "malloc");
nallocs++;
void* r = libc_malloc(sz);;
if (!recursive && nallocs > 4000000) {
void* r = libc_malloc(sz);
if (!recursive) {
recursive = true;
printf("malloc'd: %p\n", r);
raise(SIGTRAP);
printf("\nmalloc %p\n", r);
recursive = false;
}
return r;
}
extern "C" void* relloc(void* p, size_t sz) {
static void *(*libc_realloc)(void*, size_t) = (void* (*)(void*, size_t))dlsym(RTLD_NEXT, "realloc");
void* r = libc_realloc(p, sz);
if (!recursive) {
recursive = true;
printf("\nrealloc %p %p\n", p, r);
recursive = false;
}
return r;
...
...
@@ -65,13 +75,13 @@ extern "C" void* malloc(size_t sz) {
extern "C" void free(void* p) {
static void (*libc_free)(void*) = (void (*)(void*))dlsym(RTLD_NEXT, "free");
if (!recursive
&& nallocs > 4000000
) {
if (!recursive) {
recursive = true;
printf("free: %p\n", p);
raise(SIGTRAP);
printf("\nfree %p\n", p);
if (p == (void*)0x1c4c780)
raise(SIGTRAP);
recursive = false;
}
nallocs--;
libc_free(p);
}
#endif
...
...
tools/process_malloc_trace.py
0 → 100644
View file @
a1227e08
lines
=
[
l
for
l
in
open
(
"out.log"
).
readlines
()
if
l
.
startswith
(
"malloc "
)
or
l
.
startswith
(
"free "
)]
freed
=
set
()
err
=
set
()
for
l
in
lines
:
if
l
.
startswith
(
"malloc"
):
p
=
l
[
7
:]
if
p
in
freed
:
freed
.
remove
(
p
)
else
:
assert
l
.
startswith
(
"free"
)
p
=
l
[
5
:]
if
p
.
startswith
(
"(nil)"
):
continue
if
p
in
freed
:
if
p
not
in
err
:
err
.
add
(
p
)
print
p
.
strip
()
freed
.
add
(
p
)
tools/process_mtrace_trace.py
0 → 100644
View file @
a1227e08
allocated
=
set
()
freed
=
set
()
reported
=
set
()
for
l
in
open
(
"malloc.trace"
).
readlines
()[
1
:]:
s
=
l
.
strip
().
split
()
if
s
[
-
3
]
==
'+'
:
p
=
s
[
-
2
]
if
p
in
freed
:
freed
.
remove
(
p
)
elif
s
[
-
2
]
==
'-'
:
p
=
s
[
-
1
]
if
p
in
freed
:
if
p
not
in
reported
:
print
"double-freed"
,
p
reported
.
add
(
p
)
freed
.
add
(
p
)
elif
s
[
-
2
]
==
'<'
:
p
=
s
[
-
1
]
assert
p
not
in
freed
,
p
freed
.
add
(
p
)
elif
s
[
-
3
]
==
'>'
:
p
=
s
[
-
2
]
if
p
in
freed
:
freed
.
remove
(
p
)
else
:
assert
0
,
l
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