Bug 6790 – buildPath using std.path.curdir segfaults
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2011-10-07T21:37:00Z
Last change time
2012-04-19T08:14:23Z
Assigned to
nobody
Creator
jonathansternberg
Comments
Comment #0 by jonathansternberg — 2011-10-07T21:37:46Z
I am using the dmd compiler and phobos library at version 2.055. This is on Linux Mint 11 with x86 architecture. To repeat the bug is a bit weird. It seems to only happen when using std.path.curdir, and only when not in the main module. The following will NOT produce the error:
import std.path; import std.stdio;
int main() {
writeln(buildPath(curdir, "a.out"));
return 0;
}
This WILL produce the error:
-- main.d
static import foobar;
int main() {
foobar.crash();
return 0;
}
-- foobar.d
module foobar;
import std.path; import std.stdio;
void crash() {
writeln(buildPath(curdir, "a.out"));
}
Compiling and running this results in a segfault. No idea why.
Workaround that seems to work is to use std.path.curdir.idup instead.
Comment #1 by jonathansternberg — 2011-11-10T16:18:31Z
As of dmd 2.056, this now throws "core.exception.OutOfMemoryError". No recompilation was needed, but recompilation resulted in the same thing.
This is probably some error in druntime.
Comment #2 by bugzilla — 2011-11-28T15:14:39Z
I am using the latest revisions of DMD, druntime and Phobos, and I can't reproduce this.
curdir is a string enum, and the only thing that happens to it in buildPath is the following:
return cast(string)(curdir ~ dirSeparator ~ "a.out");
This should be perfectly OK, as concatenation always allocates a new string. Therefore, I agree with Jacob that it is/was a bug in druntime, or perhaps DMD, but it seems to have been fixed now.
Comment #3 by bugzilla — 2011-11-28T15:21:19Z
(In reply to comment #2)
> Therefore, I agree with Jacob [...]
Why on earth did I say Jacob? :) I meant Jonathan, of course.
Comment #4 by jonathansternberg — 2011-11-28T19:53:11Z
Lars, for completeness, can you give your OS/architecture? As I said, it still happens on x86 Linux for me.
Comment #5 by bugzilla — 2011-11-29T13:15:35Z
I am on 64-bits Ubuntu Linux. However, I have tried compiling the entire toolchain (DMD, druntime and Phobos, all fresh from the Github repositories) with -m32, and used it to compile your test case, and I still can't reproduce it.
Comment #6 by bugzilla — 2012-02-01T14:41:35Z
Have you tried this with DMD 2.057, and if so, are you still experiencing the same problem?
Comment #7 by lovelydear — 2012-04-19T07:37:35Z
I think this one should be closed as "Can't reproduce". We'll reopen it if it happens again.