GC debug fixes #1197
GC debug fixes #1197
Conversation
a3b73f4
to
f901b5f
Compare
// Note: Some of these need to be set globally | ||
// (for the entire Druntime) in the Makefile | ||
// instead of uncommenting the lines here. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICT it's only SENTINEL that needs to be set globally to disable some unittests.
I don't see something obvious. Do you have more info on where the tests are failing? |
The ones I disabled in 03ab3d6. |
f901b5f
to
c73e6b7
Compare
|
Is there more information about this? I'm currently debugging memory corruption and was thinking about trying Valgrind. However gcstub won't help find use-after-free bugs in cases where the GC incorrectly collected something.
The problem is with SENTINEL, not MEMSTOMP, so probably an alignment issue somewhere. |
I've got something working here: CyberShadow/druntime@pull-20150323-233811-gc-debug...valgrind |
Pretty interesting. |
Works, because gcstub never collects, that's a problem on it's own though. |
No, that's not the problem I'm talking about. Say you allocated an object X, and stored the only pointer somewhere the GC can't see it. The GC collects it and allocates a new object at the same address. The code that then attempts to refer to X causes memory corruption. This is a nontrivial problem even with Valgrind integration. What I'd need to do is make the GC collect objects (and stomp on freed memory), but instead of reusing the memory, keep allocating new memory, so that dangling pointers cause Valgrind errors. Any advice on the easiest way to do this? |
Just comment out the cleaning of the free bits. |
Somewhere in sweep. |
The runFinalizer functions pass the wrong size to the
(replace p with q for the small object pool). |
@@ -23,6 +23,8 @@ module gc.gc; | |||
//debug = LOGGING; // log allocations / frees | |||
//debug = MEMSTOMP; // stomp on memory | |||
//debug = SENTINEL; // add underrun/overrrun protection | |||
// note: this needs to be enabled globally in the makefiles | |||
// (-debug=SENTINEL) instead of uncommented here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should restrict the comment to building the unittests, e.g. ".. when building druntime unittests".
Please fixup the finalizer if you find time @CyberShadow. |
Sorry, forgot about this pull. Will do. |
No description provided.