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

A field in a structure is sometimes protected by Mutex, but sometimes unprotected. #7222

Open
2 tasks
BurtonQin opened this issue Apr 28, 2020 · 2 comments
Open
2 tasks

Comments

@BurtonQin
Copy link
Contributor

What version of Hugo are you using (hugo version)?

master branch, commit c03ea2b

What happened:
A field in a structure is sometimes protected by Mutex, but sometimes unprotected.
This may lead to data race.
There are 2 such cases:

What you expected to happen:
Data race

@bep bep modified the milestones: v0.70, v0.71 Apr 28, 2020
@bep bep modified the milestones: v0.71, v0.72 May 18, 2020
@bep bep modified the milestones: v0.72, v0.73 May 31, 2020
@bep bep modified the milestones: v0.73, v0.74 Jun 23, 2020
@bep bep modified the milestones: v0.74, v0.75 Jul 13, 2020
@bep bep modified the milestones: v0.75, v0.76 Sep 14, 2020
@bep bep modified the milestones: v0.76, v0.77 Oct 6, 2020
@bep bep modified the milestones: v0.77, v0.78 Oct 30, 2020
@paskal
Copy link

paskal commented Mar 22, 2021

The only way to properly protect t.text (as it's used elsewhere after return) is to make a deep copy of it and return the pointer to that copy instead of the original: that's a cure worse than the disease, in my opinion, as it will complicate code for no clear benefit.

@bep
Copy link
Member

bep commented Mar 22, 2021

This may lead to data race.

Only if it's read/write from multiple go routines at the same time.

  1. postTransform is, to my knowledge, always done in 1 thread and before the templates gets used.
  2. Any concurrency issue with t.text should be addressed in the source (Go stdlib).

Also, note that we have a fair amount of tests that run this code successfully with the -race flag enabled.

@bep bep modified the milestones: v0.78, v0.83 Apr 23, 2021
@bep bep modified the milestones: v0.83, v0.84 May 3, 2021
@bep bep modified the milestones: v0.84, v0.85 Jun 18, 2021
@bep bep modified the milestones: v0.85, v0.86 Jul 5, 2021
@bep bep removed this from the v0.86 milestone Jul 26, 2021
@bep bep modified the milestones: v0.117.0, v0.118.0 Aug 30, 2023
@bep bep modified the milestones: v0.118.0, v0.119.0 Sep 15, 2023
@bep bep modified the milestones: v0.119.0, v0.120.0 Oct 4, 2023
@bep bep modified the milestones: v0.120.0, v0.121.0 Oct 31, 2023
@bep bep modified the milestones: v0.121.0, v0.122.0 Dec 6, 2023
@bep bep modified the milestones: v0.122.0, v0.123.0, v0.124.0 Jan 27, 2024
@bep bep modified the milestones: v0.124.0, v0.125.0 Mar 4, 2024
@bep bep modified the milestones: v0.125.0, v0.126.0 Apr 23, 2024
@bep bep modified the milestones: v0.126.0, v0.127.0 May 15, 2024
@bep bep modified the milestones: v0.127.0, v0.128.0 Jun 8, 2024
@bep bep modified the milestones: v0.128.0, v0.129.0 Jun 21, 2024
@bep bep modified the milestones: v0.129.0, v0.131.0 Jul 22, 2024
@bep bep modified the milestones: v0.131.0, v0.133.0 Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants