D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7293 - dmd 2.057 segfault/crash - std.regex.match(string, string)
Summary: dmd 2.057 segfault/crash - std.regex.match(string, string)
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P2 major
Assignee: No Owner
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2012-01-14 19:43 UTC by Jerry Quinn
Modified: 2012-01-29 10:38 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jerry Quinn 2012-01-14 19:43:34 UTC
Ubuntu 11.10, x86_64, compiling the following crashes the compiler:

import std.regex;
class C {
  Regex!dchar re;
  auto m = match("", "");
}

jlquinn@wyvern:~/src$ ~/dmd2/linux/bin64/dmd -c bug1.d 
Segmentation fault
Comment 1 Gary Slopsema 2012-01-18 17:43:53 UTC
Confirmed on Windows 7 x86.
Comment 2 Stewart Gordon 2012-01-27 05:26:43 UTC
Please remember to:
- assign keywords as appropriate
- make summary lines specific to the bug
- change platform/OS to "All" if you witness it on something different from what the reporter reported it on.

Even smaller testcase:
-----
import std.regex;
auto m = match("", "");
-----

Crash report (DMD 2.057, Windows Vista 32-bit:
-----
  Problem Event Name:	APPCRASH
  Application Name:	dmd.exe
  Application Version:	0.0.0.0
  Application Timestamp:	00000000
  Fault Module Name:	dmd.exe
  Fault Module Version:	0.0.0.0
  Fault Module Timestamp:	00000000
  Exception Code:	c0000005
  Exception Offset:	0003c6b2
  OS Version:	6.0.6002.2.2.0.768.3
  Locale ID:	2057
  Additional Information 1:	482b
  Additional Information 2:	fe3cbbb77b564d5f0cb2cc6fc75b3c2f
  Additional Information 3:	73f1
  Additional Information 4:	1e2657c1444006182528bd2953dbb394
Comment 3 yebblies 2012-01-27 08:44:29 UTC
On win32 I get the following:

DMD v2.058 DEBUG
..\..\phobos\std\regex.d(6278): Error: malloc cannot be interpreted at compile t
ime, because it has no available source code
..\..\phobos\std\regex.d(6278):        called from here: enforce(malloc(size),de
legate pure nothrow @safe const(char)[]()
{
return null;
}
)
..\..\phobos\std\regex.d(6449):        called from here: (RegexMatch!(string,Tho
mpsonMatcher) __ctmp919 = _D3std5regex50__T10RegexMatchTAyaS273std5regex15Thomps
onMatcherZ10RegexMatch6__initZ;
 , __ctmp919).this(regex(re,""),input)
testx.d(4):        called from here: match("","")

So it might actually be ice_on_invalid code... and also a phobos bug.
Comment 4 Walter Bright 2012-01-28 23:26:36 UTC
I get what yebblies is getting. No dmd seg fault. Changed to Phobos issue.
Comment 5 kraybourne 2012-01-29 02:43:43 UTC
Confirm Segmentation fault on OSX 10.7.2 DMD 2.057

Faults
$  echo 'import std.regex; auto m = match("", "");' > bug.d
$  dmd -c -m32 bug.d
Segmentation fault: 11
$  dmd -c -m64 bug.d
Segmentation fault: 11
$  _


Works
$  echo 'import std.regex; void main(){ auto m = match("", ""); }' > bug.d
$  dmd -c -m32 bug.d
$  dmd -c -m64 bug.d
$  _
Comment 6 Stewart Gordon 2012-01-29 07:24:35 UTC
(In reply to comment #4)
> I get what yebblies is getting.

On what DMD version?  Note that yebblies is using a version that isn't even released yet.

> No dmd seg fault. Changed to Phobos issue.

So far, four of us have confirmed that the compiler IS segfaulting.  This is definitely a bug in the compiler.

It may have gone away by itself in 2.058, but this doesn't change the fact that the bug is there in 2.057.  If the segfault has been fixed in 2.058, then mark it as such.

If there is bad code in Phobos, this is a separate bug from the fact that the code crashes DMD.  As such, it warrants a separate bug report.
Comment 7 Walter Bright 2012-01-29 10:38:32 UTC
(In reply to comment #6)
> It may have gone away by itself in 2.058, but this doesn't change the fact that
> the bug is there in 2.057.  If the segfault has been fixed in 2.058, then mark
> it as such.

The usual practice is to mark things as fixed if they are fixed in the most recent github build, which naturally will be ahead of the latest release.

I mark as "worksforme" things that were (apparently) recently fixed as part of another bug fix, and I don't have a specific commit to log what did the fix. In other words, this was an unrecognized duplicate of another bug. Which bug it was, I do not know, nor do I wish to spend a couple hours figuring out which one it was.

Please reopen if a seg fault can be produced on this with the latest github version. I cannot reproduce a seg fault.

I agree that if this is a phobos bug, it should go under a separate issue.