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

xgotext SIGSEGV #102

Open
Tom5521 opened this issue Jan 13, 2025 · 2 comments
Open

xgotext SIGSEGV #102

Tom5521 opened this issue Jan 13, 2025 · 2 comments
Assignees
Labels

Comments

@Tom5521
Copy link

Tom5521 commented Jan 13, 2025

Please describe your issue

Is this a bug, an improvement, a proposal or something else? Describe it.

It's a bug

What's the expected behaviour, the current behaviour and the steps to reproduce it?

The expected behavior is that it generates the corresponding .pot file in the specified directory, but
the current behavior is that it returns this error

$ xgotext -in . -out po
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x58c18f]

goroutine 40 [running]:
go/types.(*Checker).handleBailout(0xc00066e700, 0xc001079c80)
        /usr/lib/go/src/go/types/check.go:404 +0x88
panic({0x64eec0?, 0x84f5f0?})
        /usr/lib/go/src/runtime/panic.go:785 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0x6eac50, 0x852640})
        /usr/lib/go/src/go/types/sizes.go:229 +0x30f
go/types.(*Config).sizeof(...)
        /usr/lib/go/src/go/types/sizes.go:334
go/types.representableConst.func1({0x6eac50?, 0x852640?})
        /usr/lib/go/src/go/types/const.go:77 +0x86
go/types.representableConst({0x6ebe08, 0xc000381700}, 0xc00066e700, 0x852640, 0xc0010795d0)
        /usr/lib/go/src/go/types/const.go:93 +0x173
go/types.(*Checker).representation(0xc00066e700, 0xc0012b6040, 0x852640)
        /usr/lib/go/src/go/types/const.go:257 +0x65
go/types.(*Checker).implicitTypeAndValue(0xc00066e700, 0xc0012b6040, {0x6eac50, 0x852640})
        /usr/lib/go/src/go/types/expr.go:377 +0x2d7
go/types.(*Checker).assignment(0xc00066e700, 0xc0012b6040, {0x6eac50, 0x852640}, {0x691eb4, 0x14})
        /usr/lib/go/src/go/types/assignments.go:70 +0x451
go/types.(*Checker).initVar(0xc00066e700, 0xc0002d9c80, 0xc0012b6040, {0x691eb4, 0x14})
        /usr/lib/go/src/go/types/assignments.go:181 +0x428
go/types.(*Checker).varDecl(0xc00066e700, 0xc0002d9c80, {0xc000e1c320, 0x1, 0x1}, {0x0, 0x0}, {0x6eb488, 0xc0010a89a0})
        /usr/lib/go/src/go/types/decl.go:514 +0x19b
go/types.(*Checker).objDecl(0xc00066e700, {0x6ee338, 0xc0002d9c80}, 0x0)
        /usr/lib/go/src/go/types/decl.go:188 +0x9a5
go/types.(*Checker).packageObjects(0xc00066e700)
        /usr/lib/go/src/go/types/resolver.go:714 +0x454
go/types.(*Checker).checkFiles(0xc00066e700, {0xc000677740, 0xb, 0xb})
        /usr/lib/go/src/go/types/check.go:459 +0x15a
go/types.(*Checker).Files(0xc00013e000?, {0xc000677740?, 0xc0006768a0?, 0x4?})
        /usr/lib/go/src/go/types/check.go:422 +0x75
golang.org/x/tools/go/packages.(*loader).loadPackage(0xc00013e000, 0xc00049eee0)
        /home/tom/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:1001 +0x74f
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
        /home/tom/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:838 +0x1a9
sync.(*Once).doSlow(0x0?, 0x0?)
        /usr/lib/go/src/sync/once.go:76 +0xb4
sync.(*Once).Do(...)
        /usr/lib/go/src/sync/once.go:67
golang.org/x/tools/go/packages.(*loader).loadRecursive(0x0?, 0x0?)
        /home/tom/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:826 +0x3b
golang.org/x/tools/go/packages.(*loader).refine.func2(0x0?)
        /home/tom/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:761 +0x26
created by golang.org/x/tools/go/packages.(*loader).refine in goroutine 1
        /home/tom/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:760 +0xc7a

Comments

I run this in go version 1.23.4

@leonelquinteros
Copy link
Owner

Hey @Tom5521 , I'm not able to reproduce your issue, could you share detailed steps or resource files you're using (translation files) to identify the bug?

Thanks!

@bhaible
Copy link

bhaible commented Feb 1, 2025

I reproduce it as follows:

On Ubuntu 24.04, with go version 1.22 installed.
In an empty directory, create hello3.go with this contents:

package main

import (
	"fmt"
	"github.com/leonelquinteros/gotext"
)

func main () {
	// Specify localedir, locale, domain.
	gotext.Configure ("./locale", "fr_FR", "hello")

	fmt.Println (gotext.Get ("Hello world!"))
	fmt.Println (gotext.Get ("Hello %s", "Dolly"))
}

and go.mod with this contents:

module hello
go 1.11
require github.com/leonelquinteros/gotext v1.7.0

Then

chmod -R u+w ~/go/; rm -rf ~/go/
go get github.com/leonelquinteros/gotext
go run hello3.go
go get github.com/leonelquinteros/gotext/cli/xgotext
go install github.com/leonelquinteros/gotext/cli/xgotext
mkdir -p po
PATH=${GOPATH-$HOME/go}/bin:$PATH xgotext -default hello -in . -out po

Result:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
        panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x58a26f]

goroutine 353 [running]:
go/types.(*Checker).handleBailout(0xc000356c00, 0xc00068fc60)
        /usr/lib/go-1.22/src/go/types/check.go:367 +0x88
panic({0x641f20?, 0x8344a0?})
        /usr/lib/go-1.22/src/runtime/panic.go:770 +0x132
go/types.(*StdSizes).Sizeof(0x0, {0x6dcfd0, 0x8373c0})
        /usr/lib/go-1.22/src/go/types/sizes.go:228 +0x30f
go/types.(*Config).sizeof(...)
        /usr/lib/go-1.22/src/go/types/sizes.go:333
go/types.representableConst.func1({0x6dcfd0?, 0x8373c0?})
        /usr/lib/go-1.22/src/go/types/const.go:76 +0x9e
go/types.representableConst({0x6de058, 0x82d0a0}, 0xc000356c00, 0x8373c0, 0x0)
        /usr/lib/go-1.22/src/go/types/const.go:92 +0x192
go/types.(*Checker).arrayLength(0xc000356c00, {0x6dd350, 0xc0006fc7c0?})
        /usr/lib/go-1.22/src/go/types/typexpr.go:510 +0x2d3
go/types.(*Checker).typInternal(0xc000356c00, {0x6dd500, 0xc000117320}, 0x0)
        /usr/lib/go-1.22/src/go/types/typexpr.go:299 +0x49d
go/types.(*Checker).definedType(0xc000356c00, {0x6dd500, 0xc000117320}, 0xc00068f248?)
        /usr/lib/go-1.22/src/go/types/typexpr.go:180 +0x37
go/types.(*Checker).varType(0xc000356c00, {0x6dd500, 0xc000117320})
        /usr/lib/go-1.22/src/go/types/typexpr.go:145 +0x25
go/types.(*Checker).structType(0xc000356c00, 0xc00013af30, 0xc00013af30?)
        /usr/lib/go-1.22/src/go/types/struct.go:113 +0x19f
go/types.(*Checker).typInternal(0xc000356c00, {0x6dd530, 0xc00030e228}, 0xc00082a2d0)
        /usr/lib/go-1.22/src/go/types/typexpr.go:316 +0x1345
go/types.(*Checker).definedType(0xc000356c00, {0x6dd530, 0xc00030e228}, 0x10?)
        /usr/lib/go-1.22/src/go/types/typexpr.go:180 +0x37
go/types.(*Checker).typeDecl(0xc000356c00, 0xc00082a2d0, 0xc000226f40, 0x0)
        /usr/lib/go-1.22/src/go/types/decl.go:615 +0x44d
go/types.(*Checker).objDecl(0xc000356c00, {0x6e02b8, 0xc00082a2d0}, 0x0)
        /usr/lib/go-1.22/src/go/types/decl.go:197 +0xa7f
go/types.(*Checker).packageObjects(0xc000356c00)
        /usr/lib/go-1.22/src/go/types/resolver.go:681 +0x425
go/types.(*Checker).checkFiles(0xc000356c00, {0xc0003005d0, 0x5, 0x5})
        /usr/lib/go-1.22/src/go/types/check.go:408 +0x1a5
go/types.(*Checker).Files(...)
        /usr/lib/go-1.22/src/go/types/check.go:372
golang.org/x/tools/go/packages.(*loader).loadPackage(0xc0000da0e0, 0xc0004464c0)
        /home/bruno/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:1001 +0x76f
golang.org/x/tools/go/packages.(*loader).loadRecursive.func1()
        /home/bruno/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:838 +0x1a9
sync.(*Once).doSlow(0x0?, 0x0?)
        /usr/lib/go-1.22/src/sync/once.go:74 +0xc2
sync.(*Once).Do(...)
        /usr/lib/go-1.22/src/sync/once.go:65
golang.org/x/tools/go/packages.(*loader).loadRecursive(0x0?, 0x0?)
        /home/bruno/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:826 +0x4a
golang.org/x/tools/go/packages.(*loader).refine.func2(0x0?)
        /home/bruno/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:761 +0x26
created by golang.org/x/tools/go/packages.(*loader).refine in goroutine 1
        /home/bruno/go/pkg/mod/golang.org/x/[email protected]/go/packages/packages.go:760 +0xc9a

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

No branches or pull requests

3 participants