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

Windows SetTooltip invalid memory address #158

Closed
psidex opened this issue Jun 22, 2020 · 7 comments · Fixed by #206
Closed

Windows SetTooltip invalid memory address #158

psidex opened this issue Jun 22, 2020 · 7 comments · Fixed by #206

Comments

@psidex
Copy link

psidex commented Jun 22, 2020

PS C:\Users\Simon\go\src\github.com\psidex\EACS> go run .\cmd\test\main.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x6608e6]

goroutine 6 [running]:
github.com/getlantern/systray.(*winTray).setTooltip(0x921fa0, 0x6f6138, 0x1d, 0xc000086058, 0xc0000311b8)
        C:/Users/Simon/go/pkg/mod/github.com/getlantern/systray@v1.0.3/systray_windows.go:226 +0x66
github.com/getlantern/systray.SetTooltip(0x6f6138, 0x1d)
        C:/Users/Simon/go/pkg/mod/github.com/getlantern/systray@v1.0.3/systray_windows.go:852 +0x4c
main.OnReady()
        C:/Users/Simon/go/src/github.com/psidex/EACS/cmd/test/main.go:8 +0x3d
github.com/getlantern/systray.Register.func2(0xc000014180, 0x706528)
        C:/Users/Simon/go/pkg/mod/github.com/getlantern/systray@v1.0.3/systray.go:91 +0x45
created by github.com/getlantern/systray.Register
        C:/Users/Simon/go/pkg/mod/github.com/getlantern/systray@v1.0.3/systray.go:89 +0xe3
exit status 2

here is the contents of main.go:

package main

import (
	"github.com/getlantern/systray"
)

func OnReady() {
	systray.SetTooltip("This is the tooltip text")
}

func OnExit() {
	// No cleanup needed.
}

func main() {
	systray.Run(OnReady, OnExit)
}
@psidex psidex changed the title windows SetTooltip invalid memory address Windows SetTooltip invalid memory address Jun 22, 2020
@ldstein
Copy link
Contributor

ldstein commented Jul 17, 2020

FWIW, I'm also experiencing this issue.

I'm observing if I run the compiled exe 6-7 times, ~30% will fail with the above mentioned error.

v0.9.0 doesn't appear to be affected. 1.0.0, 1.0.1, 1.0.2 and 1.0.3 exhibit this issue.

Tested with:

  • Windows 10 x64
  • Go 1.14.1
  • TDC-GCC 5.1.0-2 and TDM-GCC 9.2.0

Edit - This appears to fix the issue - just need to ensure systray.SetIcon() is run before systray.SetTooltip().

@ldstein
Copy link
Contributor

ldstein commented Jul 23, 2020

Can't comment on v1.0.4 specifically, but have been giving 4c7e35b4e5114211b7c7c3b57484c56de802767a a good workout for the last couple of days. Fixed all the issues for me (only tested on Windows).

@psidex
Copy link
Author

psidex commented Jul 24, 2020

I'm still experiencing the same error on 1.0.4 (using the same code in my initial issue):

PS C:\Users\Simon\go\src\github.com\psidex\trayTest> go run .\main.go
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x6608ae]

goroutine 6 [running]:
github.com/getlantern/systray.(*winTray).setTooltip(0x923260, 0x6f5060, 0x18, 0x0, 0x0)
        C:/Users/Simon/go/pkg/mod/github.com/getlantern/systray@v1.0.4/systray_windows.go:238 +0xce
github.com/getlantern/systray.SetTooltip(0x6f5060, 0x18)
        C:/Users/Simon/go/pkg/mod/github.com/getlantern/systray@v1.0.4/systray_windows.go:899 +0x4c
main.OnReady()
        C:/Users/Simon/go/src/github.com/psidex/trayTest/main.go:8 +0x3d
github.com/getlantern/systray.Register.func2(0xc000014180, 0x7075d0)
        C:/Users/Simon/go/pkg/mod/github.com/getlantern/systray@v1.0.4/systray.go:91 +0x45
created by github.com/getlantern/systray.Register
        C:/Users/Simon/go/pkg/mod/github.com/getlantern/systray@v1.0.4/systray.go:89 +0xe3
exit status 2

But I can confirm that setting the icon before setting the tooltip does work.

@psidex
Copy link
Author

psidex commented Jul 24, 2020

I am also getting an Invalid menu handle error when using AddMenuItem before using SetIcon.

All of these issues seem to be linked to something that SetIcon does?

It all works if the first thing I do is call SetIcon, but trying to use any other method before that (such as AddMenuItem or SetTooltip) causes errors

@joesis joesis self-assigned this Sep 14, 2020
@getlantern getlantern deleted a comment from gravataLonga Mar 1, 2021
@getlantern getlantern deleted a comment from joesis Mar 1, 2021
@getlantern getlantern deleted a comment from gravataLonga Mar 1, 2021
@getlantern getlantern deleted a comment from joesis Mar 1, 2021
@getlantern getlantern deleted a comment from gravataLonga Mar 1, 2021
@getlantern getlantern deleted a comment from gravataLonga Mar 1, 2021
@getlantern getlantern deleted a comment from joesis Mar 1, 2021
@Etua
Copy link

Etua commented Apr 3, 2021

My program would crash about 50% of the time because of this issue until I started adding 500ms delay before calling setToolTip as suggested by @ldstein in #164 and it seems to have worked. Why you ask? I have no idea but there is something glitchy going inside the library.

@gravataLonga
Copy link

Sorry, why comment's was deleted? Only for curiosity..

@leejoys
Copy link

leejoys commented Jan 13, 2022

This way it's working:

func main() {
	systray.Run(onReady, onExit)
}

func onReady() {
	systray.SetTitle("Sup")
	systray.SetIcon(ico)
	systray.SetTooltip("Sup")
}

func onExit() {

}

But this way fall to panic:

func main() {
	systray.Run(onReady, onExit)
}

func onReady() {
	systray.SetTitle("Sup")
	systray.SetTooltip("Sup")
	systray.SetIcon(ico)

}

func onExit() {

}

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

Successfully merging a pull request may close this issue.

6 participants