Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #956 (closed defect: fixed)

Opened 13 years ago

Last modified 11 years ago

Weird Regex crash

Reported by: torhu Assigned to: jascha
Priority: major Milestone: 0.99.8
Component: Tango Version: 0.99.5 Jascha
Keywords: Cc:,


This is with Tango r3319, which I assume will become 0.99.5.

import tango.text.Regex;

void main()
	Regex re = new Regex(r"(\d{1,3}\.){3}\d{1,3}(:\d{1,5})?");

	bool result = re.test("");

Using DMD 1.027 (also tried 1.026), bud 3.04, on winxp 32 bit.

If I build like this and then run, I get an AV:

c:\prog\test\tango>dmd regextest.d
c:\prog\dmd\bin\..\..\dm\bin\link.exe regextest,,,user32+kernel32/noi+tango-user

object.Exception: Access Violation

If I add -g to the command line, it runs fine and prints 'true'. If I build with bud, there's no problem. The relevant difference is probably that bud builds and links the relevant tango modules, so no code is taken from tango-user-dmd.lib.

This is my sc.ini:

version=7.51 Build 020

DFLAGS="-I%@P%\..\..\import\tangobos;%@P%\..\import\tango;%@P%\..\..\import\tango;%@P%\..\import\;%@P%\..\..\import\;" -version=Tango -defaultlib=tango-base-dmd.lib -debuglib=tango-base-dmd.lib -L+tango-user-dmd.lib


sortie.txt (43.2 kB) - added by xxltux on 04/14/08 11:16:19.
Tango compilation outpu

Change History

03/01/08 20:28:04 changed by torhu

Forgot to mention how I build tango. I use build-dmd.bat, build-tango.bat, and build-win32.bat. In that order. I built Tango with 1.026 first, and the rebuilt it with 1.027, and got the same results.

03/04/08 09:34:12 changed by jascha

  • version changed from trunk to 0.99.5 Jascha.

(follow-up: ↓ 4 ) 03/24/08 21:06:52 changed by xxltux

I'm using DMD 1.028, NT5.1 and I've same problem with this : import; import tango.text.RegEx?;

int main(char[][] args) {

Stdout.formatln ("Hello world!");

return 0;


It's work perfectly if I comment the second line

(in reply to: ↑ 3 ) 03/25/08 00:10:35 changed by torhu

Replying to xxltux: Please create a new ticket if this is a different problem. And please put code in triple braces like {{{ code goes here }}}.

Please describe exactly what happens when you try. And Regex is not being used in your testcase.

Please don't reply here if this is really a different issue.

03/25/08 11:33:24 changed by xxltux

I think it's the same problem, if I just import the module RegEx?, the exe crash with the same message(object.Exception: Access Violation). If I use really RegEx?, it's same but if the RegEx? module is not imported, it's work.

import; import tango.text.RegEx??;

int main(char[][] args) {

Stdout.formatln ("Hello world!");

return 0;

} }}}

This code with an stdout at the start of main doesn't print "start" but print object.Exception: Access Violation :

import tango.text.Regex;

void main()
	Regex re = new Regex(r"(\d{1,3}\.){3}\d{1,3}(:\d{1,5})?");

	bool result = re.test("");

03/25/08 20:58:53 changed by torhu

You're right, I get an AV when I just import Regex without using it. Now I'm using 0.99.5, dmd 1.027 on winxp. Tango is built with the backtrace hack.

import tango.text.Regex;

int main(char[][] args) {

    Stdout.formatln ("Hello world!");

    return 0;


(follow-up: ↓ 8 ) 03/26/08 10:33:46 changed by xxltux

It's a linker problems, if I link manually the exe with tango-base, there isn't problems. Your code work perfectly. But I don't know why the linker don't make an error.

(in reply to: ↑ 7 ) 03/27/08 05:39:20 changed by torhu

Replying to xxltux: tango-base? Don't you mean tango-user-dmd.lib?

03/27/08 12:28:44 changed by xxltux

No, but it's very strange!

D:\>dmd main.d

object.Exception: Access Violation

D:\>dmd main.d tango-base-dmd.lib

Hello world!


This is my sc.ini :

version=7.51 Build 020

; Switch the commenting on LIB and DFLAGS to toggle back to Phobos!
; LIB="%@P%\..\lib";\dm\lib
; DFLAGS="-I%@P%\..\src\phobos"
DFLAGS="-I%@P%\..\import" -version=Tango -defaultlib=tango-base-dmd -debuglib=tango-base-dmd -L+tango-user-dmd.lib

03/27/08 12:41:45 changed by xxltux

  • cc changed from to,

03/27/08 15:08:57 changed by xxltux

I get this with DDBG :

No symbols available from ntdll.dll
ntdll.dll loaded at 0x7c910000
No symbols available from KERNEL32.dll
KERNEL32.dll loaded at 0x7c800000
No symbols available from SHELL32.dll
SHELL32.dll loaded at 0x7c9d0000
No symbols available from ADVAPI32.dll
ADVAPI32.dll loaded at 0x77da0000
No symbols available from RPCRT4.dll
RPCRT4.dll loaded at 0x77e50000
No symbols available from Secur32.dll
Secur32.dll loaded at 0x77fc0000
No symbols available from GDI32.dll
GDI32.dll loaded at 0x77ef0000
No symbols available from USER32.dll
USER32.dll loaded at 0x7e390000
No symbols available from msvcrt.dll
msvcrt.dll loaded at 0x77be0000
No symbols available from SHLWAPI.dll
SHLWAPI.dll loaded at 0x77f40000
Unknown breakpoint hit at ntdll.dll (0x7c911230) thread(2500)
No symbols available from IMM32.dll
IMM32.dll loaded at 0x76320000
No symbols available
unknown DLL loaded
No symbols available from ole32.dll
ole32.dll loaded at 0x774a0000
No symbols available from FLTLIB.DLL
FLTLIB.DLL loaded at 0x5e100000
No symbols available from WINSTA.dll
WINSTA.dll loaded at 0x762f0000
No symbols available from NETAPI32.dll
NETAPI32.dll loaded at 0x6fee0000
No symbols available from COMCTL32.dll
COMCTL32.dll loaded at 0x77390000
No symbols available from COMCTL32.dll
COMCTL32.dll loaded at 0x58b50000
Unhandled Exception: EXCEPTION_ACCESS_VIOLATION(0xc0000005) at tango.text.Regex.
bsetState (0x0040a1be) thread(2500)
#0 class tango.text.Regex.TDFA!(dchar).TDFA.SubsetState tango.text.Regex.TDFA!(d
char).TDFA.epsilonClosure(class tango.text.Regex.TDFA!(dchar).TDFA.SubsetState,
class tango.text.Regex.TDFA!(dchar).TDFA.SubsetState, void*) () from Regex

04/07/08 14:18:14 changed by miasma

I think this is the same problem. One friend just tried this example from the manual using the last version of Tango:

import tango.text.Regex;
void main()
    foreach(m; Regex("ab").search("qwerabcabcababqwer"))
            Stdout.formatln("{}[{}]{}", m.pre, m.match(0),;

And it caused "object.Exception: Access Violation". Adding the lib to the build command fixed it (dmd main.d tango-base-dmd.lib).

04/07/08 19:21:04 changed by xxltux

I think so

04/07/08 21:13:40 changed by kris

There is a known Access Violation in the released version of Tango regex (995), which is fixed in SVN trunk. We'll get a new release out soon

04/08/08 08:39:26 changed by jascha

make sure you follow miasma's suggestion to explicitly recompile the user-libs, or don't use libs at all (use rebuild instead). there have been several reports of this problem disappearing after this was changed. if the problem persists, use the latest trunk or wait for 0.99.6.

04/08/08 15:51:41 changed by xxltux

I've the same problem with trunk 3418

04/10/08 09:57:26 changed by jascha

i cannot reproduce the crash using 3418 or 3426. could you paste your exact library- and compiler versions as well as your build command and source code? if you use a build tool like rebuild, please make sure to paste the verbose output (option -v for rebuild).

04/13/08 10:26:34 changed by xxltux

I'm using DMD 1.028 and the latest trunk(3428). I don't use rebuild but build-dmd.bat...

04/14/08 11:16:19 changed by xxltux

  • attachment sortie.txt added.

Tango compilation outpu

04/27/08 09:09:45 changed by larsivi

  • milestone changed from 0.99.6 to 0.99.7.

04/27/08 17:11:42 changed by xxltux

With "-g" option on windows, the program doesn't crash ( DMD 1.029 and svn 3468 ).

06/17/08 12:31:02 changed by torhu

I think I saw the same thing, so I wasn't able to debug the crash.

07/02/08 21:30:20 changed by jascha

  • milestone changed from 0.99.7 to 1.0.

01/06/09 23:29:55 changed by larsivi

Could people test this with the latest Tango revision? I got some reports that it seems to not manifest there.

01/08/09 20:12:10 changed by larsivi

  • status changed from new to closed.
  • resolution set to fixed.
  • milestone changed from 1.0 to 0.99.8.

Reported as fixed here.

05/24/10 16:50:03 changed by torhu

Yup, unable to reproduce this with 0.99.9. Of course, that only means I bump into another regex bug...