Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tour: Range and Close example code fails to run #505

Open
ollipa opened this issue Jun 7, 2018 · 1 comment
Open

tour: Range and Close example code fails to run #505

ollipa opened this issue Jun 7, 2018 · 1 comment

Comments

@ollipa
Copy link

ollipa commented Jun 7, 2018

Context: https://tour.golang.org/concurrency/4

The example code fails to run in the section "Range and Close" with an error message:

/usr/local/go/src/sync/pool.go:9:2: read /usr/local/go/src/runtime/symtab_test.go: read /usr/local/go/src/runtime/symtab_test.go: cannot allocate memory

Program exited.

The code compiles and runs if I change any line in the example code (eg. adding a new empty line).

@bgadrian
Copy link
Contributor

bgadrian commented Jun 7, 2018

The problem doesn't reproduce 100% of the times, you need to open a new tab (after a few runs or when you modify the txt it works.
From what I could debug is a matter of encoding or missing characters from the initial HTML text value.

The first request does NOT work (returns error).
The 2nd is the correct one (it works).
The differences is at the last 3 lines, after Println(i)

curl 'https://tour.golang.org/compile' -H 'cookie: ' -H 'origin: https://tour.golang.org' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-GB,en;q=0.9,en-US;q=0.8,ro;q=0.7' -H 'x-requested-with: XMLHttpRequest' -H 'pragma: no-cache' -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36' -H 'content-type: application/x-www-form-urlencoded; charset=UTF-8' -H 'accept: application/json, text/javascript, */*; q=0.01' -H 'cache-control: no-cache' -H 'authority: tour.golang.org' -H 'referer: https://tour.golang.org/concurrency/4' -H 'dnt: 1' --data 'version=2&body=package+main%0A%0Aimport+(%0A%09%22fmt%22%0A)%0A%0Afunc+fibonacci(n+int%2C+c+chan+int)+%7B%0A%09x%2C+y+%3A%3D+0%2C+1%0A%09for+i+%3A%3D+0%3B+i+%3C+n%3B+i%2B%2B+%7B%0A%09%09c+%3C-+x%0A%09%09x%2C+y+%3D+y%2C+x%2By%0A%09%7D%0A%09close(c)%0A%7D%0A%0Afunc+main()+%7B%0A%09c+%3A%3D+make(chan+int%2C+10)%0A%09go+fibonacci(cap(c)%2C+c)%0A%09for+i+%3A%3D+range+c+%7B%0A%09%09fmt.Println(i)%0A%09%7D%0A%7D%0A' --compressed

curl 'https://tour.golang.org/compile' -H 'cookie: ' -H 'origin: https://tour.golang.org' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-GB,en;q=0.9,en-US;q=0.8,ro;q=0.7' -H 'x-requested-with: XMLHttpRequest' -H 'pragma: no-cache' -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36' -H 'content-type: application/x-www-form-urlencoded; charset=UTF-8' -H 'accept: application/json, text/javascript, */*; q=0.01' -H 'cache-control: no-cache' -H 'authority: tour.golang.org' -H 'referer: https://tour.golang.org/concurrency/4' -H 'dnt: 1' --data 'version=2&body=package+main%0A%0Aimport+(%0A%09%22fmt%22%0A)%0A%0Afunc+fibonacci(n+int%2C+c+chan+int)+%7B%0A%09x%2C+y+%3A%3D+0%2C+1%0A%09for+i+%3A%3D+0%3B+i+%3C+n%3B+i%2B%2B+%7B%0A%09%09c+%3C-+x%0A%09%09x%2C+y+%3D+y%2C+x%2By%0A%09%7D%0A%09close(c)%0A%7D%0A%0Afunc+main()+%7B%0A%09c+%3A%3D+make(chan+int%2C+10)%0A%09go+fibonacci(cap(c)%2C+c)%0A%09for+i+%3A%3D+range+c+%7B%0A%09%09fmt.Println(i)%0A%09%7D%0A%09%0A%7D%0A' --compressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants