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

qtmoc : invalid memory address or nil pointer dereference #763

Closed
muyuballs opened this issue Jan 11, 2019 · 6 comments
Closed

qtmoc : invalid memory address or nil pointer dereference #763

muyuballs opened this issue Jan 11, 2019 · 6 comments

Comments

@muyuballs
Copy link
Contributor

muyuballs commented Jan 11, 2019

ubuntu 18.10 + xfce
gcc version 8.2.0 (Ubuntu 8.2.0-7ubuntu1)
qt 5.12.0
go version go1.11.2 linux/amd64
go mod enabled

$ qtmoc -slow
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x684843]

goroutine 763 [running]:
golang.org/x/tools/imports.(*pass).importIdentifier(...)
	/opt/gosrc/src/golang.org/x/tools/imports/fix.go:307
golang.org/x/tools/imports.(*pass).load(0xc00f775200, 0xc00f775200)
	/opt/gosrc/src/golang.org/x/tools/imports/fix.go:339 +0x513
golang.org/x/tools/imports.fixImportsDefault(0xc0138ee000, 0xc00f774e00, 0x834571, 0x6, 0x4a4dc, 0x4c000)
	/opt/gosrc/src/golang.org/x/tools/imports/fix.go:504 +0x2f9
golang.org/x/tools/imports.Process(0x834571, 0x6, 0xc007504000, 0x4a4dc, 0x4c000, 0xc003f31e90, 0xc00025f790, 0x4e992f, 0xc008cfb978, 0x0, ...)
	/opt/gosrc/src/golang.org/x/tools/imports/imports.go:66 +0x72b
github.com/therecipe/qt/internal/cmd/moc.moc.func3(0xc007504000, 0x4a4dc, 0x4c000, 0xc0003eb4d0, 0x24)
	/opt/gosrc/src/github.com/therecipe/qt/internal/cmd/moc/moc.go:377 +0xd4
created by github.com/therecipe/qt/internal/cmd/moc.moc
	/opt/gosrc/src/github.com/therecipe/qt/internal/cmd/moc/moc.go:371 +0x3311
@therecipe
Copy link
Owner

Hey

I will look into this.
It's probably because using the binding with modules is still experimental.
Does qtdeploy work for you?

This is also related to: #755 #726

@muyuballs
Copy link
Contributor Author

😢

$ qtdeploy test desktop .
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x834775]

goroutine 462 [running]:
golang.org/x/tools/imports.(*pass).importIdentifier(...)
	/home/dev/go/src/golang.org/x/tools/imports/fix.go:309
golang.org/x/tools/imports.(*pass).load(0xc00b749d00, 0xc00b749d00)
	/home/dev/go/src/golang.org/x/tools/imports/fix.go:341 +0x525
golang.org/x/tools/imports.fixImportsDefault(0xc0152f8000, 0xc00b749900, 0x952680, 0x6, 0x4a4a8, 0x4c000)
	/home/dev/go/src/golang.org/x/tools/imports/fix.go:506 +0x2f9
golang.org/x/tools/imports.Process(0x952680, 0x6, 0xc01024e000, 0x4a4a8, 0x4c000, 0xc00e30be90, 0x0, 0x0, 0x0, 0x0, ...)
	/home/dev/go/src/golang.org/x/tools/imports/imports.go:66 +0x72b
github.com/therecipe/qt/internal/cmd/moc.moc.func3(0xc01024e000, 0x4a4a8, 0x4c000, 0xc00041b220, 0x1b)
	/home/dev/go/src/github.com/therecipe/qt/internal/cmd/moc/moc.go:377 +0xd4
created by github.com/therecipe/qt/internal/cmd/moc.moc
	/home/dev/go/src/github.com/therecipe/qt/internal/cmd/moc/moc.go:371 +0x333d

@therecipe
Copy link
Owner

Thanks, could you show me the imports of the moc.go that causes the crash?
Just run qtdeploy -debug or qtmoc -debug to see which one is created just before the crash.

Also maybe try running go clean -cache before running qtdeploy or qtmoc.
And also, which Qt version did you use to install the binding? (FastTrack, Official or PkgConfig)

Lastly, can you build and run examples from qt/internal/examples or from https://github.com/therecipe/examples?

@muyuballs
Copy link
Contributor Author

Qt: Official 5.12.0

qtmoc -debug
....
DEBU[0013] prepare                                       module=common
DEBU[0013] found 0 moc structs                           path=/dev/shm/sahot/sahot
DEBU[0013] parse                                         path=/dev/shm/sahot/sahot/sahot.go
DEBU[0013] found 0 moc structs                           path=/dev/shm/sahot
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x688a75]
$ find . |grep moc.go
./sahot/models/moc.go
./sahot/components/moc.go
$ cat -n 10  ./sahot/models/moc.go 
cat: 10: No such file or directory
     1	package models
     2	
     3	//#include <stdint.h>
     4	//#include <stdlib.h>
     5	//#include <string.h>
     6	//#include "moc.h"
     7	import "C"
     8	import (
     9		"runtime"
    10		"strings"
    11		"unsafe"
    12	
    13		"github.com/therecipe/qt"
    14		std_core "github.com/therecipe/qt/core"
    15		"gitlab.breezes.info/muyu/sahot/sahot/common"
    16		custom_common_782068m "gitlab.breezes.info/muyu/sahot/sahot/common"
    17	)
$ cat -n  ./sahot/components/moc.go
     1	package components
     2	
     3	//#include <stdint.h>
     4	//#include <stdlib.h>
     5	//#include <string.h>
     6	//#include "moc.h"
     7	import "C"
     8	import (
     9		"runtime"
    10		"strings"
    11		"unsafe"
    12	
    13		"github.com/therecipe/qt"
    14		std_core "github.com/therecipe/qt/core"
    15		"gitlab.breezes.info/muyu/sahot/sahot/common"
    16		custom_common_782068m "gitlab.breezes.info/muyu/sahot/sahot/common"
    17	)

i try move the project to GOPATH ,that working fine

@therecipe
Copy link
Owner

Thanks.

These two imports of the common pkg, under different identifiers does not look right. Maybe this causes the crash of the import tool.

Do you maybe re-use the same name for structs somewhere?

@therecipe
Copy link
Owner

Will close this, since the status is tracked here #755 (comment) now

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

No branches or pull requests

2 participants