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

Data Race in SetLogLevel #2493

Open
davidnewhall opened this issue Mar 16, 2023 · 1 comment · May be fixed by #3905
Open

Data Race in SetLogLevel #2493

davidnewhall opened this issue Mar 16, 2023 · 1 comment · May be fixed by #3905
Labels
Bug Something isn't working

Comments

@davidnewhall
Copy link

Description

My app allows changing the log level on the fly. Once in a while I get a data race because I change the log level and print a message that it was changed.

To Reproduce

I have not tried to reproduce this with minimal code, but I can if you think it would be helpful.

Expected behaviour

No data races.

Screenshots

The entire stack trace running in wails dev -race:

WARNING: DATA RACE
Write at 0x00c0001bed30 by goroutine 2725:
  github.com/wailsapp/wails/v2/internal/logger.(*Logger).SetLogLevel()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/logger/default_logger.go:48 +0x44
  github.com/wailsapp/wails/v2/pkg/runtime.LogSetLogLevel()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/pkg/runtime/log.go:103 +0x5c
  github.com/Notifiarr/toolbarr/pkg/logs.(*Logger).Setup()
      /Users/david/go/src/github.com/Notifiarr/toolbarr/pkg/logs/logs.go:88 +0x390
  github.com/Notifiarr/toolbarr/pkg/app.(*App).SaveConfigItem()
      /Users/david/go/src/github.com/Notifiarr/toolbarr/pkg/app/app.go:42 +0xc34
  runtime.call64()
      /opt/homebrew/Cellar/go/1.20.1/libexec/src/runtime/asm_arm64.s:480 +0x74
  reflect.Value.Call()
      /opt/homebrew/Cellar/go/1.20.1/libexec/src/reflect/value.go:370 +0xc0
  github.com/wailsapp/wails/v2/internal/binding.(*BoundMethod).Call()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/binding/boundMethod.go:73 +0x478
  github.com/wailsapp/wails/v2/internal/frontend/dispatcher.(*Dispatcher).processCallMessage()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/dispatcher/calls.go:45 +0x608
  github.com/wailsapp/wails/v2/internal/frontend/dispatcher.(*Dispatcher).ProcessMessage()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/dispatcher/dispatcher.go:40 +0x1f4
  github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin.(*Frontend).processMessage.func1()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/desktop/darwin/frontend.go:318 +0xb4

Previous read at 0x00c0001bed30 by goroutine 2505:
  github.com/wailsapp/wails/v2/internal/logger.(*Logger).Debug()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/logger/default_logger.go:77 +0x50
  github.com/wailsapp/wails/v2/internal/frontend/devserver.newExternalAssetsHandler.func1()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/devserver/external.go:35 +0x134
  net/http/httputil.(*ReverseProxy).ServeHTTP()
      /opt/homebrew/Cellar/go/1.20.1/libexec/src/net/http/httputil/reverseproxy.go:387 +0x690
  github.com/wailsapp/wails/v2/internal/frontend/devserver.newExternalAssetsHandler.func4()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/devserver/external.go:72 +0x14c
  net/http.HandlerFunc.ServeHTTP()
      /opt/homebrew/Cellar/go/1.20.1/libexec/src/net/http/server.go:2122 +0x64
  github.com/wailsapp/wails/v2/pkg/assetserver.(*AssetServer).ServeHTTP()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/pkg/assetserver/assetserver.go:152 +0x964
  github.com/wailsapp/wails/v2/internal/frontend/devserver.(*DevWebServer).Run.func3()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/devserver/devserver.go:118 +0x98
  github.com/labstack/echo/v4.(*Echo).add.func1()
      /Users/david/go/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:536 +0x9c
  github.com/labstack/echo/v4.(*Echo).ServeHTTP()
      /Users/david/go/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:646 +0x34c
  net/http.serverHandler.ServeHTTP()
      /opt/homebrew/Cellar/go/1.20.1/libexec/src/net/http/server.go:2936 +0x688
  net/http.(*conn).serve()
      /opt/homebrew/Cellar/go/1.20.1/libexec/src/net/http/server.go:1995 +0x1ef4
  net/http.(*Server).Serve.func3()
      /opt/homebrew/Cellar/go/1.20.1/libexec/src/net/http/server.go:3089 +0x60

Goroutine 2725 (running) created at:
  github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin.(*Frontend).processMessage()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/desktop/darwin/frontend.go:317 +0x68c
  github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin.(*Frontend).startMessageProcessor()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/desktop/darwin/frontend.go:111 +0xa0
  github.com/wailsapp/wails/v2/internal/frontend/desktop/darwin.NewFrontend.func2()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/desktop/darwin/frontend.go:103 +0x3c

Goroutine 2505 (running) created at:
  net/http.(*Server).Serve()
      /opt/homebrew/Cellar/go/1.20.1/libexec/src/net/http/server.go:3089 +0xba8
  github.com/labstack/echo/v4.(*Echo).Start()
      /Users/david/go/pkg/mod/github.com/labstack/echo/[email protected]/echo.go:663 +0x1a8
  github.com/wailsapp/wails/v2/internal/frontend/devserver.(*DevWebServer).Run.func4()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/devserver/devserver.go:125 +0x68
  github.com/wailsapp/wails/v2/internal/frontend/devserver.(*DevWebServer).Run.func5()
      /Users/david/go/pkg/mod/github.com/wailsapp/wails/[email protected]/internal/frontend/devserver/devserver.go:130 +0x60

Attempted Fixes

I have not tried to workaround this yet.

System Details

Running on an M1 Mac. Go 1.20.1 and wails 2.4.0.

Additional context

<3

@davidnewhall davidnewhall added the Bug Something isn't working label Mar 16, 2023
@leaanthony leaanthony linked a pull request Nov 23, 2024 that will close this issue
@leaanthony
Copy link
Member

Please try the above PR to see if this fixes your problem. If you are unsure how to do this, please follow this guide. Let us know how you get on 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants