Skip to content

x/website: playground execution doesn't finish normally, but no error message is shown #76694

@NanoUser3000

Description

@NanoUser3000

What is the URL of the page with the issue?

https://go.dev/play/

What is your user agent?

I don't think this will be relevant
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:145.0) Gecko/20100101 Firefox/145.0
(The problem occurred also in Google Chrome on another computer having Windows 11)

Screenshot

Image

What did you do?

I wrote some code for Advent of Code 2015, day 10, part 1

Here is the code:

package main

import (
	"fmt"
	"strings"
)

func part1(input string) {
	input = strings.TrimSpace(input)

	for range 40 {
		input = lookAndSay(input)
	}

	fmt.Println("part 1:", len(input))
}

func lookAndSay(s string) string {
	var result string

	for i := 0; i < len(s); {
		b := s[i]
		var j = 0
		for ; i < len(s) && s[i] == b; i, j = i+1, j+1 {
		}
		result += fmt.Sprintf("%d%c", j, b)
	}
	return result
}

func main() {
	fmt.Println("Start")
	part1(input)
	fmt.Println("End")
}

const input = `3113322113` 

What did you expect to see?

I expected to see "Start", then answer, then "End" in the output.

Or, potentially, an error. (e.g. timeout). Now that I think about it, this is what I would actually expect, given how intensive the 40 iterations turn out to be (you can find the details below).

What did you see instead?

There is 40 in one place in the code. For 40 and more (100, 1_000_000) iterations the program seems to be stopped before it finishes, yet the output and message are as if everything went ok (with the beginning of the output present, and a gray message Program exited., which is the same for normal, successful execution.

For 20 iterations, the program finishes no problem, there isn't a bug in it.

Some more info

Program consistently finishes for 25 iterations, and consistently doesn't for 30.
Also, for 30 I occasionally get timeout running program (picture below), followed by what happens usually (and I believe is not acceptable): beginning of the output and a Program exited. message.

Image

Here is some info about how computationally intense is the execution.
The following are times measured on my computer (some info fwiw: 11th Gen Intel(R) Core(TM) i5-1135G7 @ 2.40GHz, 16GiB memory),
and lengths of string processed during execution.

iterations time string lengths
20 ~0.05s up to ~1600
30 ~-0.15s ~23k
35 ~0.7s ~90k
40 ~8s ~330k

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.website

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions