Giter Site home page Giter Site logo

`next` hangs about delve HOT 6 CLOSED

go-delve avatar go-delve commented on August 22, 2024
`next` hangs

from delve.

Comments (6)

ebfe avatar ebfe commented on August 22, 2024

Minimized the example too much. This one shows the same behaviour and makes it more obvious why next shouldn't hang.

package main

import "fmt"

func count(ch chan <- int) {
        x := 0
        for {
                ch <- x
                tmp := x
                tmp += 1
                x = tmp
        }
}

func main() {
        ch := make(chan int)
        go count(ch)
        for {
====>       x := <- ch
            fmt.Println(x) 
        }
}

from delve.

derekparker avatar derekparker commented on August 22, 2024

Hmm.. I have an idea why this may be happening. Thanks for the error reproducing code. I'll wrap a test around this and start working on a fix.

from delve.

derekparker avatar derekparker commented on August 22, 2024

Did not mean for the last push to close this -- reopening as it's occasionally still an issue.

from delve.

cam72cam avatar cam72cam commented on August 22, 2024

@derekparker I think the issue is with how you are stepping forward threads that are currently blocked waiting for a resource. I have been working on a project (https://github.com/cam72cam/burrow) to create a ncurses interface for delve. Here is the output of program posted above.

https://gfycat.com/ImpoliteLastBushsqueaker#
The gify came out a bit funny, so here are the commands to replicate

:break main.main
:break fmt.Println
:continue
:continue
:continue
:continue
s (next key)
s (next key)
s (next key)

The continue runs to the next breakpoint and only the main thread's context changes there.
When you call Next() on all of the threads, the ones that I think are blocking/waiting (runtime.usleep) are forced forward which causes something to go wrong.

from delve.

derekparker avatar derekparker commented on August 22, 2024

@cam72cam that's definitely the issue, and was solved partly by a recent commit last night which enabled next to handle goroutine thread context switching a little better.

There are certainly issues where Delve can continue a thread (M) that is blocked waiting for a G - which can cause Delve to hang. I'm thinking through some solutions to this problem and I have some experimental fixes hanging around on another branch. There are some fun and interesting problems around how to coordinate threads in such a way that the scheduler thread on the traced process is still able to do its job.

from delve.

ebfe avatar ebfe commented on August 22, 2024

Seems fixed as of afa3a9c. Thanks

from delve.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.