-
-
Notifications
You must be signed in to change notification settings - Fork 411
Conversation
|
Thanks for your pull request, @wilzbach! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. |
2ff15e8 to
a830054
Compare
|
I think there is a different problem here! This does not segfault: import core.memory;
void main()
{
int *x = null;
GC.free(x);
} |
src/core/memory.d
Outdated
| x = null; | ||
| if (x !is null) | ||
| { | ||
| GC.free(&x); |
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.
This seems wrong, shouldn't it be GC.free(x) ?
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.
Yeah, looks like I was a bit too fast. Thanks!
a830054 to
0723ae5
Compare
|
OK, I see you fixed that problem. But now I'm slightly confused! Because extracting out the problem: void main()
{
int *ptr = null;
GC.free(&ptr);
}This segfaults, but this: void main()
{
int *ptr = new int(1);
GC.free(&ptr);
}DOESN'T segfault. Neither is a valid heap pointer, so why does it segfault at all? The first thing In any case, a bug for another day. Your changes LGTM. |
|
Hah, I think I know why it was segfaulting. Because of the new ProxyGC! Attempting to free a pointer before actually allocating any pointer will do this: https://github.com/dlang/druntime/blob/master/src/gc/impl/proto/gc.d#L140, which equates to a segfault when compiled in release mode. |
|
This does fix a bug, though ( |
See also: #2104 (comment)