-
Notifications
You must be signed in to change notification settings - Fork 10
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
Fields set with SetField
leak
#131
Comments
This could be happening because |
Reference: #126 Reference: #131 Since the `LoggerOpts` struct contains slice and map fields, it is important to ensure any modifications occur on copies of those slices and maps, otherwise the memory reference can wind up being shared. Consumers should always be able to create a new `context.Context` without worrying about shared data. This change introduces a `Copy()` method for `LoggerOpts` and implements it for option modifier functions which adjust a map or slice.
Reference: #126 Reference: #131 Since the `LoggerOpts` struct contains slice and map fields, it is important to ensure any modifications occur on copies of those slices and maps, otherwise the memory reference can wind up being shared. Consumers should always be able to create a new `context.Context` without worrying about shared data. This change introduces a `Copy()` method for `LoggerOpts` and implements it for option modifier functions which adjust a map or slice.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
terraform-plugin-log version
Relevant provider source code
Expected Behavior
The log entry generated by calling
tflog.Trace(originalCtx, "original logger")
should only have the fieldkey1
set and not have the field setkey2
set.Actual Behavior
Both
key1
andkey2
are set when callingtflog.Trace(originalCtx, "original logger")
Steps to Reproduce
TestSetFieldSequential
References
This may be related to #126, since the field map is being modified in-place.
The text was updated successfully, but these errors were encountered: