Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: data race onSystray.SetCurrentConfigFile#1012

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
dido18 wants to merge18 commits intomain
base:main
Choose a base branch
Loading
fromdatarace-on-config-access

Conversation

dido18
Copy link
Contributor

@dido18dido18 commentedJan 21, 2025
edited
Loading

Please check if the PR fulfills these requirements

  • The PR has no duplicates (please search among thePull Requests
    before creating one)
  • Tests for the changes have been added (for bug fixes / features)
  • What kind of change does this PR introduce?
    Fix a data race on the config set to the Systray struct.
  • What is the current behavior?
    When the agent starts, there is a data race on theSetCurrentConfigFile method called by two different go routines.
2025/01/10 14:35:07 stderr: WARNING: DATA RACE2025/01/10 14:35:07 stderr: Write at 0x0000018b31e8 by goroutine 16:2025/01/10 14:35:07 stderr: github.com/arduino/arduino-create-agent/systray.(*Systray).SetCurrentConfigFile()2025/01/10 14:35:07 stderr: /home/dido/code/arduino/arduino-create-agent/systray/systray.go:102 +0x79d2025/01/10 14:35:07 stderr: main.loop()2025/01/10 14:35:07 stderr: /home/dido/code/arduino/arduino-create-agent/main.go:261 +0x7912025/01/10 14:35:07 stderr:2025/01/10 14:35:07 stderr: Previous write at 0x0000018b31e8 by main goroutine:2025/01/10 14:35:07 stderr: main.main()2025/01/10 14:35:07 stderr: /home/dido/code/arduino/arduino-create-agent/main.go:149 +0x2392025/01/10 14:35:07 stderr:2025/01/10 14:35:07 stderr: Goroutine 16 (running) created at:2025/01/10 14:35:07 stderr: main.main()2025/01/10 14:35:07 stderr: /home/dido/code/arduino/arduino-create-agent/main.go:145 +0xfa2025/01/10 14:35:07 stderr: ==================
  • What is the new behavior?
    The config is read in the main and theSetCurrentConfigFile on Systray is called by the main goroutine (and not in the otherloop go routine)
  • Does this PR introduce a breaking change?
  • Other information:
  • Move the logic to read the config.ini file into the '/config/config.go` module
  • Add Unit tests (only for LINUX OS)
  • Testing thelegacy behaviours is not easy (the config.ini file in the old location is copied into the new home location). It relies on theos.Executable() calls

@codecov-commenter
Copy link

codecov-commenter commentedJan 21, 2025
edited
Loading

Codecov Report

Attention: Patch coverage is58.97436% with16 lines in your changes missing coverage. Please review.

Project coverage is 21.59%. Comparing base(1b94ccc) to head(870fac5).

Files with missing linesPatch %Lines
config/config.go74.19%7 Missing and 1 partial⚠️
main.go0.00%8 Missing⚠️
Additional details and impacted files
@@            Coverage Diff             @@##             main    #1012      +/-   ##==========================================+ Coverage   20.14%   21.59%   +1.44%==========================================  Files          42       42                Lines        3222     3228       +6     ==========================================+ Hits          649      697      +48+ Misses       2488     2442      -46- Partials       85       89       +4
FlagCoverage Δ
unit21.59% <58.97%> (+1.44%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

@per1234per1234 added topic: codeRelated to content of the project itself type: imperfectionPerceived defect in any part of project labelsJan 29, 2025
@dido18dido18 changed the title fix: data race on config concurrent access fix: data race on SetCurrentConfigFileJan 29, 2025
@dido18dido18 marked this pull request as ready for reviewJanuary 29, 2025 13:58
@dido18dido18 requested a review froma teamJanuary 29, 2025 13:58
@dido18dido18 changed the title fix: data race on SetCurrentConfigFile fix: data race onSystray.SetCurrentConfigFileJan 29, 2025
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I am not sure which is the difference theconfigPath is still accessed concurrently by the main thread and in the loop.

Comment on lines +176 to +179
if configPath == nil {
log.Panic("configPath is nil")
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

configPath should always be not nil, can we avoid the check?

@per1234per1234 linked an issueFeb 6, 2025 that may beclosed by this pull request
3 tasks
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@lucarin91lucarin91lucarin91 left review comments

@alessio-peruginialessio-peruginialessio-perugini approved these changes

Assignees

@dido18dido18

Labels
topic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Data race on SetCurrentConfigFile call
5 participants
@dido18@codecov-commenter@lucarin91@alessio-perugini@per1234

[8]ページ先頭

©2009-2025 Movatter.jp