Skip to content

Commit 38c2151

Browse files
myitcvdmitshur
authored andcommitted
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.
1 parent f7c5653 commit 38c2151

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ test:
2020
- diff -u <(echo -n) <(go list ./compiler/natives/src/...) # All those packages should have // +build js.
2121
- gopherjs install -v net/http # Should build successfully (can't run tests, since only client is supported).
2222
- >
23-
gopherjs test --minify -v --short
23+
ulimit -s 10000 && gopherjs test --minify -v --short
2424
github.com/gopherjs/gopherjs/tests
2525
github.com/gopherjs/gopherjs/tests/main
2626
github.com/gopherjs/gopherjs/js

tool.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,9 +750,30 @@ func runNode(script string, args []string, dir string, quiet bool) error {
750750
}
751751

752752
if runtime.GOOS != "windows" {
753-
allArgs = append(allArgs, "--stack_size=10000", script)
753+
// We've seen issues with stack space limits causing
754+
// recursion-heavy standard library tests to fail (e.g., see
755+
// https://github.com/gopherjs/gopherjs/pull/669#issuecomment-319319483).
756+
//
757+
// There are two separate limits in non-Windows environments:
758+
//
759+
// - OS process limit
760+
// - Node.js (V8) limit
761+
//
762+
// GopherJS fetches the current OS process limit, and sets the
763+
// Node.js limit to the same value. So both limits are kept in sync
764+
// and can be controlled by setting OS process limit. E.g.:
765+
//
766+
// ulimit -s 10000 && gopherjs test
767+
//
768+
var r syscall.Rlimit
769+
err := syscall.Getrlimit(syscall.RLIMIT_STACK, &r)
770+
if err != nil {
771+
return fmt.Errorf("failed to get stack size limit: %v", err)
772+
}
773+
allArgs = append(allArgs, fmt.Sprintf("--stack_size=%v", r.Cur/1000)) // Convert from bytes to KB.
754774
}
755775

776+
allArgs = append(allArgs, script)
756777
allArgs = append(allArgs, args...)
757778

758779
node := exec.Command("node", allArgs...)

0 commit comments

Comments
 (0)