Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
fn recursion(n: int) {
println!("deep: {:d}", n);
recursion(n + 1);
}
fn main() {
recursion(0);
}
deep: 12952
There are not many persons who know what wonders are opened to them in the
stories and visions of their youth; for when as children we listen and dream,
we think but half-formed thoughts, and when as men we try to remember, we are
dulled and prosaic with the poison of life. But some of us awake in the night
with strange phantasms of enchanted hills and gardens, of fountains that sing
in the sun, of golden cliffs overhanging murmuring seas, of plains that stretch
down to sleeping cities of bronze and stone, and of shadowy companies of heroes
that ride caparisoned white horses along the edges of thick forests; and then
we know that we have looked back through the ivory gates into that world of
wonder which was ours before we were wise and unhappy.
fatal runtime error: assertion failed: !ptr.is_null()
Aborted
// test.go
package main
import "fmt"
func recursion(n int) {
fmt.Println(n)
recursion(n+1)
}
func main() {
recursion(0)
}
$ go run test.go | tail
runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflow
runtime stack:
runtime.throw(0x1646a0)
/usr/local/go/src/pkg/runtime/panic.c:464 +0x69
runtime.newstack()
/usr/local/go/src/pkg/runtime/stack.c:295 +0x3bc
runtime.morestack()
/usr/local/go/src/pkg/runtime/asm_amd64.s:225 +0x61
// ... урезанный stack trace от собственно функции recustion
exit status 2
9277301
9277302
9277303
9277304
9277305
9277306
9277307
9277308
9277309
9277310
task '<main>' has overflowed its stack. Если закомментить println, так и происходит. Видимо, переполнение происходит именно в println и это не перехватывается.
Вышел Rust 0.9