Wiki Roadmap Timeline Tickets New Ticket Source Search Help / Guide About Trac Login

Ticket #195 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

Returns of arrays from tango.text.Regexp is broken on OS X

Reported by: lorrden Assigned to: lindquist
Priority: critical Milestone: Delay
Component: backend Version: release 0.9
Keywords: darwin Cc:

Description

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");
}

Attachments

test.d (99 bytes) - added by lorrden on 01/26/09 13:14:18.
testcase

Change History

01/26/09 13:14:18 changed by lorrden

  • attachment test.d added.

testcase

01/29/09 11:26:05 changed by ChristianK

Can't reproduce on x86-32 linux. How do you know it's an array return issue?

Can you try again with hg tip? Quite a few Mac-related fixes have been merged since 0.9.

01/29/09 13:36:06 changed by lorrden

  • summary changed from Returns of arrays are broken on OS X to Returns of arrays from tango.text.Regexp is broken on OS X.

Updated ldc to tip, no change, crash does not happen in the simpler case if tango.io.Stdout is not included. Issue is not a return of array issue, simple return of arrays work fine. This only happens when tango.io.Stdout is used in conjunction with the regexps, also craches on match() call, but only if Stdout is included.

02/02/09 12:17:35 changed by lindquist

the -output-ll issue is most likely fixed in llvm 2.5.

could I get you to build tango with debug info (your test too), and provide a gdb stack trace ?

you might want to use -gc if your gdb doesn't support D.

02/05/09 15:33:52 changed by mandel

I can confirm the problem:

(gdb) r
Starting program: /Users/mwarning/main 
Reading symbols for shared libraries ++. done
match
match
match
match

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000008
0x0001c838 in _D5tango2io7Console12_staticDtor2FZv ()
(gdb)

02/05/09 17:20:06 changed by mandel

with debug symbols:

(gdb) bt
#0  0x0001c71b in _D5tango2io7Console7Console6Output5flushMFZC5tango2io7Console7Console6Output (this=0x0) at Console.d:311
#1  0x0001c32d in _D5tango2io7Console12_staticDtor2FZv () at Console.d:650
Current language:  auto; currently minimal

LDC r943, Tango r4310

03/03/09 09:58:58 changed by lindquist

  • milestone set to Delay.

Delayed until a more reasonable test case is produced.

04/01/09 18:11:37 changed by mandel

The test case works when another module is given on the command line that declares some variable.

ldc main.d foo.d

main will now run without bus error when there is a variable declared in A:

module foo;
uint i;

(foo.d isn't even imported in main.d)

05/13/09 17:28:23 changed by mandel

"ldc main.d" works now.

05/14/09 03:14:37 changed by ChristianK

Does that mean this issue can be closed or is

ldc main.d foo.d

still broken?

05/14/09 04:56:22 changed by mandel

  • status changed from new to closed.
  • resolution set to fixed.

All test cases in this ticket are working now. Ticket can be closed.

Copyright © 2008, LDC Development Team.