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

x/playground: program continues running after timeout #56543

Open
orizerah opened this issue Nov 3, 2022 · 2 comments
Open

x/playground: program continues running after timeout #56543

orizerah opened this issue Nov 3, 2022 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@orizerah
Copy link

orizerah commented Nov 3, 2022

What is the URL of the page with the issue?

https://go.dev/play/p/nFK61FSRjMa

What is your user agent?

Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Safari/537.36 Edg/103.0.1264.71

Screenshot

image

What did you do?

I was playing with channels, trying to understand when a channel is blocked, and I managed to make the program to continue working even after getting the timeout prompt.
Here's a snippet of the code:

// You can edit this code!
// Click here and start typing.
package main

import (
	"fmt"
	"sync"
	"time"
)

func w(c chan<- int) {
	for {
		time.Sleep(time.Second * 1)
		fmt.Println("Sending number 1")
		c <- 1
	}
}

func main() {
	var wg sync.WaitGroup
	c := make(chan int)
	go func(wg *sync.WaitGroup, c chan<- int) {
		defer wg.Done()
		w(c)
	}(&wg, c)

	for r := range c {
		fmt.Printf("Got Number %d", r)
	}
}

What did you expect to see?

I expected the program to stop after getting timeout, and in general, for something to crash after the program continued

What did you see instead?

The program runs forever

@gopherbot gopherbot added this to the Unreleased milestone Nov 3, 2022
@seankhliao seankhliao changed the title x/website: x/playground: program continues running after timeout Nov 3, 2022
@seankhliao
Copy link
Member

cc @toothrot

@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed website labels Nov 3, 2022
@bcmills
Copy link
Contributor

bcmills commented Nov 3, 2022

The program doesn't run forever. It is using the faketime implementation, so it buffers up to some amount of timestamped output and then plays that back. The amount of output in the buffer may cover a very long wall-time interval, even though the amount of time to simulate that interval in the playground was actually much shorter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants