Git Product home page Git Product logo

Comments (5)

gabyhelp avatar gabyhelp commented on August 25, 2024

Similar Issues

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

from go.

guox33 avatar guox33 commented on August 25, 2024

the loaded package is "google.golang.org/protobuf/reflect/protoreflect"
it starts with struct EnumValueDescriptor

from go.

timothy-king avatar timothy-king commented on August 25, 2024

The version of x/tools v0.11.0 (from the stack trace) is fairly out of date so you may want to try updating to see if this fixes the issue already.

I am not yet able to reproduce this with go1.20.5 (from the go env) with golang.org/x/tools v0.11.0 and google.golang.org/protobuf v1.34.2. What version of google.golang.org/protobuf/reflect/protoreflect are you analyzing?

Here is what I am doing to try to reproduce this:

# mkdir and cd into it
% cat go.mod 
module example.com/x

go 1.20

require (
        golang.org/x/tools v0.11.0
        google.golang.org/protobuf v1.34.2
)

require (
        golang.org/x/mod v0.12.0 // indirect
        golang.org/x/sys v0.10.0 // indirect
)
% cat m.go
package main

import (
        "log"

        "golang.org/x/tools/go/packages"
        "golang.org/x/tools/go/ssa"
        "golang.org/x/tools/go/ssa/ssautil"

        _ "google.golang.org/protobuf/reflect/protoreflect"
)

func main() {
        fp := "."
        cfg := &packages.Config{
                Mode: packages.NeedSyntax | packages.NeedTypesInfo |
                        packages.NeedTypesSizes | packages.NeedTypes | packages.NeedImports |
                        packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles,
                Dir: fp,
        }
        ps, err := packages.Load(cfg, "google.golang.org/protobuf/reflect/protoreflect")
        if err != nil {
                log.Fatal(err)
                return
        }
        if en := packages.PrintErrors(ps); en > 0 {
                for _, tp := range ps {
                        for _, e := range tp.Errors {
                                err = e
                                break
                        }
                        if err != nil {
                                log.Fatal(err)
                                break
                        }
                }
                return
        }
        prog, sps := ssautil.AllPackages(ps, ssa.InstantiateGenerics)
        // p.ssaFs = prog.Fset
        needAst := true /*conf.needAst*/
        if needAst {
                for _, sp := range sps {
                        sp.SetDebugMode(true)
                }
        }
        prog.Build()

        for _, pkg := range sps {
                for k, m := range pkg.Members {
                        log.Println(pkg.String(), k, ":", m.String())
                }
        }
}
% go1.20.5 build
% ./x # Prints many many members so it is loading and building.

Can you give more details for how to reproduce the crash?

from go.

guox33 avatar guox33 commented on August 25, 2024

The version of x/tools v0.11.0 (from the stack trace) is fairly out of date so you may want to try updating to see if this fixes the issue already.

I am not yet able to reproduce this with go1.20.5 (from the go env) with golang.org/x/tools v0.11.0 and google.golang.org/protobuf v1.34.2. What version of google.golang.org/protobuf/reflect/protoreflect are you analyzing?

Here is what I am doing to try to reproduce this:

# mkdir and cd into it
% cat go.mod 
module example.com/x

go 1.20

require (
        golang.org/x/tools v0.11.0
        google.golang.org/protobuf v1.34.2
)

require (
        golang.org/x/mod v0.12.0 // indirect
        golang.org/x/sys v0.10.0 // indirect
)
% cat m.go
package main

import (
        "log"

        "golang.org/x/tools/go/packages"
        "golang.org/x/tools/go/ssa"
        "golang.org/x/tools/go/ssa/ssautil"

        _ "google.golang.org/protobuf/reflect/protoreflect"
)

func main() {
        fp := "."
        cfg := &packages.Config{
                Mode: packages.NeedSyntax | packages.NeedTypesInfo |
                        packages.NeedTypesSizes | packages.NeedTypes | packages.NeedImports |
                        packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles,
                Dir: fp,
        }
        ps, err := packages.Load(cfg, "google.golang.org/protobuf/reflect/protoreflect")
        if err != nil {
                log.Fatal(err)
                return
        }
        if en := packages.PrintErrors(ps); en > 0 {
                for _, tp := range ps {
                        for _, e := range tp.Errors {
                                err = e
                                break
                        }
                        if err != nil {
                                log.Fatal(err)
                                break
                        }
                }
                return
        }
        prog, sps := ssautil.AllPackages(ps, ssa.InstantiateGenerics)
        // p.ssaFs = prog.Fset
        needAst := true /*conf.needAst*/
        if needAst {
                for _, sp := range sps {
                        sp.SetDebugMode(true)
                }
        }
        prog.Build()

        for _, pkg := range sps {
                for k, m := range pkg.Members {
                        log.Println(pkg.String(), k, ":", m.String())
                }
        }
}
% go1.20.5 build
% ./x # Prints many many members so it is loading and building.

Can you give more details for how to reproduce the crash?

thanks for replying. the problem was solved after I updated x/tools to version v0.22.0
I can't neither reproduce this problem with your code, sorry that I can't provide you with the loaded repo, it's a company property.
thanks again.

from go.

guox33 avatar guox33 commented on August 25, 2024

solved by updating x/gools to the latest version

from go.

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.