The following program craches on darwin-x86 / Mac OS X:
import tango.io.Stdout;
import tango.text.Regex;
void main(char[][] args) {
foreach(m; Regex("ab").search("abcabcabab"))
{
Stdout("match").newline;
}
}
The program prints match 4 times as can be expected and then dies with a SIGBUS.
The following is reported by the system:
Thread 0 Crashed:
0 test 0x000336a9 _D6object10getMonitorFC6ObjectZPS6object7Monitor + 9
Thread 0 crashed with X86 Thread State (32-bit):
eax: 0x00000000 ebx: 0xbffff8ec ecx: 0x00201e00 edx: 0x00000008
edi: 0x00000000 esi: 0x00000000 ebp: 0xbffff87c esp: 0xbffff6f8
ss: 0x0000001f efl: 0x00010282 eip: 0x000336a9 cs: 0x00000017
ds: 0x0000001f es: 0x0000001f fs: 0x00000000 gs: 0x00000037
cr2: 0x00000004
Note that if -output-ll is used, then an assertion in LLVM will fail:
localhost:test $ ldc -output-ll test.d
Assertion failed: (C != '"' && "Illegal character in LLVM value name!"), function PrintLLVMName, file /Users/holm/Projects/ldc/llvm-2.4/lib/VMCore/AsmWriter.cpp, line 161.
Abort trap
The crash and assertion failure does not happen without the for each loop.
The following example is simpler and gives the same result:
import tango.text.Regex;
void main(char [][]args) {
auto x = Regex("ab").search("abcabcabab");
}