Skip to content

Conversation

@moonchen
Copy link
Contributor

Lock count variable was left uninitialized, causing assertions to fail.
This change initializes the debug data so they work properly. Also add
a similar check to the locking side.

Lock count variable was left uninitialized, causing assertions to fail.
This change initializes the debug data so they work properly.  Also add
a similar check to the locking side.
X(std::atomic<bool> _exclusive;)
X(std::atomic<int> _shared;)
X(std::atomic<bool> _exclusive{false};)
X(std::atomic<int> _shared{0};)
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't necessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to this: https://en.cppreference.com/w/cpp/atomic/atomic/atomic

The default constructor is trivial: no initialization takes place other than zero initialization of static and thread-local objects. std::atomic_init may be used to complete initialization.

I also ran into an uninitialized value during local testing, which drove this change.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, sorry, I thought the std::atomic constructor always zero initialized, even for stack instances.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem!

@maskit maskit added this to the 10.0.0 milestone Aug 17, 2022
@maskit maskit merged commit 2e31ef8 into apache:master Aug 17, 2022
@zwoop
Copy link
Contributor

zwoop commented Aug 23, 2022

Cherry-picked to v9.2.x

@zwoop zwoop modified the milestones: 10.0.0, 9.2.0 Aug 23, 2022
zwoop pushed a commit that referenced this pull request Aug 23, 2022
Lock count variable was left uninitialized, causing assertions to fail.
This change initializes the debug data so they work properly.  Also add
a similar check to the locking side.

(cherry picked from commit 2e31ef8)
cmcfarlen pushed a commit to cmcfarlen/trafficserver that referenced this pull request Aug 23, 2022
Lock count variable was left uninitialized, causing assertions to fail.
This change initializes the debug data so they work properly.  Also add
a similar check to the locking side.
masaori335 pushed a commit to masaori335/trafficserver that referenced this pull request Feb 21, 2023
* asf/9.2.x:
  Updated ChangeLog
  utilize proxy.config.hostdb.host_file.interval config variable (apache#9039)
  Remove plugin parent_select unused symbols (apache#9023)
  Require use of 'override' keyword when valid. (apache#8737)
  Fix compile error on macOS (apache#9047)
  Validate that content length header matches object size on cache read (apache#8976)
  Fix reload memory leak (apache#9041)
  Update prepare_proxy_verifier.sh to work in non-git directories (apache#9048)
  Change linux/fs include to build with glibc 2.36 (apache#9027)
  ts::shared_mutex - Fix lock counting for debug (apache#9040)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants