Permalink
Browse files

Set stack_size from ulimit; set ulimit to 10000 in CI. (#687)

The goal of this change is to fix intermittent test failures we've started seeing
recently:

	=== RUN   TestMaxExecDepth
	FAIL	text/template	2.272s

In 1f89545, the --stack_size flag was
passed to Node.js. In nodejs/node#14567, it was pointed
out that the value of ulimit -s must be >= the value of --stack_size.

This change makes that so by setting --stack_size based on the current value
of ulimit, and sets ulimit to 10000 in CI.
  • Loading branch information...
myitcv authored and dmitshur committed Sep 6, 2017
1 parent f7c5653 commit 38c21514e37709765584fe7a5868cdb2f06bc4f0
Showing with 23 additions and 2 deletions.
  1. +1 −1 circle.yml
  2. +22 −1 tool.go
View
@@ -20,7 +20,7 @@ test:
- diff -u <(echo -n) <(go list ./compiler/natives/src/...) # All those packages should have // +build js.
- gopherjs install -v net/http # Should build successfully (can't run tests, since only client is supported).
- >
gopherjs test --minify -v --short
ulimit -s 10000 && gopherjs test --minify -v --short
github.com/gopherjs/gopherjs/tests
github.com/gopherjs/gopherjs/tests/main
github.com/gopherjs/gopherjs/js
View
23 tool.go
@@ -750,9 +750,30 @@ func runNode(script string, args []string, dir string, quiet bool) error {
}
if runtime.GOOS != "windows" {
allArgs = append(allArgs, "--stack_size=10000", script)
// We've seen issues with stack space limits causing
// recursion-heavy standard library tests to fail (e.g., see
// https://github.com/gopherjs/gopherjs/pull/669#issuecomment-319319483).
//
// There are two separate limits in non-Windows environments:
//
// - OS process limit
// - Node.js (V8) limit
//
// GopherJS fetches the current OS process limit, and sets the
// Node.js limit to the same value. So both limits are kept in sync
// and can be controlled by setting OS process limit. E.g.:
//
// ulimit -s 10000 && gopherjs test
//
var r syscall.Rlimit
err := syscall.Getrlimit(syscall.RLIMIT_STACK, &r)
if err != nil {
return fmt.Errorf("failed to get stack size limit: %v", err)
}
allArgs = append(allArgs, fmt.Sprintf("--stack_size=%v", r.Cur/1000)) // Convert from bytes to KB.
}
allArgs = append(allArgs, script)
allArgs = append(allArgs, args...)
node := exec.Command("node", allArgs...)

0 comments on commit 38c2151

Please sign in to comment.