Bug 61871 - FAIL: regexp from libgo testsuite on non-split stack targets
Summary: FAIL: regexp from libgo testsuite on non-split stack targets
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: go (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: 5.0
Assignee: Ian Lance Taylor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-07-21 15:33 UTC by Uroš Bizjak
Modified: 2015-01-05 23:15 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Uroš Bizjak 2014-07-21 15:33:43 UTC
regexp test from libgo testsuite FAILs on alpha (non-split stack target) due to too demanding testcase, even with 8G of RAM.

Applying the following testsuite patch, test passes without problems.

--cut here--
Index: go/regexp/all_test.go
===================================================================
--- go/regexp/all_test.go       (revision 212885)
+++ go/regexp/all_test.go       (working copy)
@@ -475,7 +475,7 @@
 
 // This ran out of stack before issue 7608 was fixed.
 func TestOnePassCutoff(t *testing.T) {
-       MustCompile(`^(?:x{1,1000}){1,1000}$`)
+//     MustCompile(`^(?:x{1,1000}){1,1000}$`)
 }
 
 func BenchmarkLiteral(b *testing.B) {
--cut here--
Comment 1 Uroš Bizjak 2014-08-05 14:31:42 UTC
Ops, I was also testing with this patch:

--cut here--
Index: go/regexp/all_test.go
===================================================================
--- go/regexp/all_test.go        (revision 213529)
+++ go/regexp/all_test.go        (working copy)
@@ -475,7 +475,7 @@
 
 // This ran out of stack before issue 7608 was fixed.
 func TestOnePassCutoff(t *testing.T) {
-       MustCompile(`^(?:x{1,1000}){1,1000}$`)
+       MustCompile(`^(?:x{1,1000}){1,500}$`)
 }
 
 func BenchmarkLiteral(b *testing.B) {
--cut here--
Comment 2 Uroš Bizjak 2014-08-07 11:58:24 UTC
The backtrace mentions "malloc/free - deadlock" and the segmentation fault happens later:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x200011d3270 (LWP 18336)]
0x0000020000e8bbac in memmove () from /lib/libc.so.6.1
(gdb) bt
#0  0x0000020000e8bbac in memmove () from /lib/libc.so.6.1
#1  0x00000200005b3a84 in gwrite (v=0x200009372f0, n=19) at /home/uros/gcc-svn/trunk/libgo/runtime/print.c:38
#2  0x00000200005b4868 in runtime_printf (s=0x200008eab4c <regexp_syntax.rune.pN22_regexp_syntax.compiler+204> ">")
    at /home/uros/gcc-svn/trunk/libgo/runtime/print.c:96
#3  0x00000200005b3014 in runtime_startpanic () at /home/uros/gcc-svn/trunk/libgo/runtime/panic.c:97
#4  0x00000200005b3160 in runtime_throw (s=0x2000093820c "malloc/free - deadlock") at /home/uros/gcc-svn/trunk/libgo/runtime/panic.c:189
#5  0x00000200005c01d4 in runtime_mallocgc (size=40, typ=0, flag=0) at /home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:116
#6  0x00000200005a4b30 in __go_new (size=2199032605516) at /home/uros/gcc-svn/trunk/libgo/runtime/go-new.c:15
#7  0x00000200008e9a34 in regexp_syntax.inst.pN22_regexp_syntax.compiler (c=0x200009372f0, op=19 '\023')
    at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:173
#8  0x00000200008eaadc in regexp_syntax.rune.pN22_regexp_syntax.compiler (c=0x200009372f0, r=..., flags=212)
    at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:267
#9  0x00000200008eaf20 in regexp_syntax.compile.pN22_regexp_syntax.compiler (c=0xc208c1a988, re=0xc208b7fce0)
    at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:110
#10 0x00000200008eb628 in regexp_syntax.compile.pN22_regexp_syntax.compiler (c=0xc208c1a988, re=<optimized out>)
    at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:154
#11 0x00000200008eb2f0 in regexp_syntax.compile.pN22_regexp_syntax.compiler (c=0xc208c1a988, re=0xc208bb0f50)
    at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:146
#12 0x00000200008eb444 in regexp_syntax.compile.pN22_regexp_syntax.compiler (c=0xc208c1a988, re=<optimized out>)
    at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:156
#13 0x00000200008eb2f0 in regexp_syntax.compile.pN22_regexp_syntax.compiler (c=0xc208c1a988, re=0xc208bb1030)
    at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:146
#14 0x00000200008eb444 in regexp_syntax.compile.pN22_regexp_syntax.compiler (c=0xc208c1a988, re=<optimized out>)
    at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:156
#15 0x00000200008eb2f0 in regexp_syntax.compile.pN22_regexp_syntax.compiler (c=0xc208c1a988, re=0xc208bb1110)
    at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:146

...

#3822 0x00000200008eb444 in regexp_syntax.compile.pN22_regexp_syntax.compiler (c=0xc208c1a988, re=<optimized out>)
    at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:156
#3823 0x00000200008eb2f0 in regexp_syntax.compile.pN22_regexp_syntax.compiler (c=0xc208c1a988, re=0xc208c2d650)
    at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:146
#3824 0x00000200008eb444 in regexp_syntax.compile.pN22_regexp_syntax.compiler (c=0xc208c1a988, re=<optimized out>)
    at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:156
#3825 0x00000200008eb444 in regexp_syntax.compile.pN22_regexp_syntax.compiler (c=0xc208c1a988, re=<optimized out>)
    at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:156
#3826 0x00000200008eb700 in regexp_syntax.Compile (re=0xc208c2d6c0) at /home/uros/gcc-svn/trunk/libgo/go/regexp/syntax/compile.go:83
#3827 0x0000000120021584 in regexp.compile (expr=..., mode=<optimized out>, longest=<optimized out>) at regexp.go:161
#3828 0x00000001200213dc in regexp.Compile (expr=...) at regexp.go:118
#3829 0x0000000120021f18 in regexp.MustCompile (str=...) at regexp.go:219
#3830 0x000000012000fa14 in regexp.TestOnePassCutoff (t=<optimized out>) at all_test.go:478
#3831 0x00000200006a96ac in testing.tRunner (test=0xc20844f288, param=<optimized out>)
    at /home/uros/gcc-svn/trunk/libgo/go/testing/testing.go:422
#3832 testing.$thunk15 (__go_thunk_parameter=<optimized out>) at /home/uros/gcc-svn/trunk/libgo/go/testing/testing.go:504
#3833 0x00000200005b774c in kickoff () at /home/uros/gcc-svn/trunk/libgo/runtime/proc.c:229
#3834 0x0000020000e42264 in ?? () from /lib/libc.so.6.1

There is quite some recursion, maybe this is the reason for a deadlock.
Comment 3 Uroš Bizjak 2014-08-07 12:12:53 UTC
The size in frame #6 is questionable:

#6  0x00000200005a4b30 in __go_new (size=2199032605516) at /home/uros/gcc-svn/trunk/libgo/runtime/go-new.c:15

(gdb) f 6
#6  0x00000200005a4b30 in __go_new (size=2199032605516) at /home/uros/gcc-svn/trunk/libgo/runtime/go-new.c:15
15        return runtime_mallocgc (size, 0, 0);
(gdb) p/x size
$10 = 0x200008eab4c
Comment 4 Uroš Bizjak 2014-08-07 13:38:10 UTC
Following patch "fixes" the test:

--cut here--
Index: runtime/proc.c
===================================================================
--- runtime/proc.c      (revision 213681)
+++ runtime/proc.c      (working copy)
@@ -51,7 +51,7 @@
 #if defined(USING_SPLIT_STACK) && defined(LINKER_SUPPORTS_SPLIT_STACK)
 # define StackMin PTHREAD_STACK_MIN
 #else
-# define StackMin 2 * 1024 * 1024
+# define StackMin 3 * 1024 * 1024
 #endif
 
 uintptr runtime_stacks_sys;
--cut here--
Comment 5 Uroš Bizjak 2014-11-16 11:53:59 UTC
The testcase now fails also on i686-linux-gnu (Fedora 20, x86_64 with -m32):

runtime: memory allocated by OS (0xef4f1000) not in usable range [0x18200000,0x98200000)
runtime: out of memory: cannot allocate 72744960-byte block (496762880 in use)
fatal error: out of memory

goroutine 32 [running]:
runtime_dopanic
	/home/uros/gcc-svn/trunk/libgo/runtime/panic.c:131
runtime_throw
	/home/uros/gcc-svn/trunk/libgo/runtime/panic.c:193
largealloc
	/home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:288
runtime_mallocgc
	/home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:234
__go_alloc
	/home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:332
__go_append
	/home/uros/gcc-svn/trunk/libgo/runtime/go-append.c:63
regexp.onePassCopy
	/ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/onepass.go:227
regexp.compileOnePass
	/ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/onepass.go:573
regexp.compile
	/ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/regexp.go:168
regexp.Compile
	/ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/regexp.go:118
regexp.MustCompile
	/ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/regexp.go:219
regexp.TestOnePassCutoff
	/ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/all_test.go:478
testing.tRunner
	/home/uros/gcc-svn/trunk/libgo/go/testing/testing.go:422
kickoff
	/home/uros/gcc-svn/trunk/libgo/runtime/proc.c:212
panic during panic

goroutine 32 [running]:
runtime_dopanic
	/home/uros/gcc-svn/trunk/libgo/runtime/panic.c:131
runtime_startpanic
	/home/uros/gcc-svn/trunk/libgo/runtime/panic.c:100
runtime_throw
	/home/uros/gcc-svn/trunk/libgo/runtime/panic.c:191
runtime_mallocgc
	/home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:121
__go_alloc
	/home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:332
callback
	/home/uros/gcc-svn/trunk/libgo/runtime/go-caller.c:50
dwarf_lookup_pc
	/home/uros/gcc-svn/trunk/libbacktrace/dwarf.c:2838
dwarf_fileline
	/home/uros/gcc-svn/trunk/libbacktrace/dwarf.c:2877
backtrace_pcinfo
	/home/uros/gcc-svn/trunk/libbacktrace/fileline.c:176
__go_file_line
	/home/uros/gcc-svn/trunk/libgo/runtime/go-caller.c:137
runtime_printcreatedby
	/home/uros/gcc-svn/trunk/libgo/runtime/proc.c:595
runtime_dopanic
	/home/uros/gcc-svn/trunk/libgo/runtime/panic.c:132
runtime_throw
	/home/uros/gcc-svn/trunk/libgo/runtime/panic.c:193
largealloc
	/home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:288
runtime_mallocgc
	/home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:234
__go_alloc
	/home/uros/gcc-svn/trunk/libgo/runtime/malloc.goc:332
__go_append
	/home/uros/gcc-svn/trunk/libgo/runtime/go-append.c:63
regexp.onePassCopy
	/ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/onepass.go:227
regexp.compileOnePass
	/ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/onepass.go:573
regexp.compile
	/ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/regexp.go:168
regexp.Compile
	/ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/regexp.go:118
regexp.MustCompile
	/ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/regexp.go:219
regexp.TestOnePassCutoff
	/ssd/uros/gcc-build/x86_64-unknown-linux-gnu/32/libgo/gotest24887/test/all_test.go:478
testing.tRunner
	/home/uros/gcc-svn/trunk/libgo/go/testing/testing.go:422
kickoff
	/home/uros/gcc-svn/trunk/libgo/runtime/proc.c:212
stack trace unavailable
FAIL: regexp
Comment 6 ian@gcc.gnu.org 2015-01-05 16:13:38 UTC
Author: ian
Date: Mon Jan  5 16:13:06 2015
New Revision: 219192

URL: https://gcc.gnu.org/viewcvs?rev=219192&root=gcc&view=rev
Log:
	PR go/61871
runtime: Increase stack size on 64-bit non-split-stack systems.

From Uros Bizjak.

Modified:
    trunk/libgo/runtime/proc.c
Comment 7 Uroš Bizjak 2015-01-05 23:15:58 UTC
Thanks, the testcase now passes on alphaev68 [1].

[1] https://gcc.gnu.org/ml/gcc-testresults/2015-01/msg00400.html