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

Declare automaticallyAppendNewlineForCustomFormatters properties as nonatomic #443

Merged
merged 2 commits into from
Feb 2, 2015

Conversation

ferrous26
Copy link
Contributor

They were implicitly atomic and do not need to be. Noticed this in a project where the relevant warnings were enabled.

In both cases that were found, the property does not need to be atomic
as they are boolean flags.
It is possible, though unlikely, that a DDTTYLogger instance will
have its _automaticallyAppendNewlineForCustomFormatters property
changed between the first and second checks of the value within
a single message logging.

Going from a NO to YES configuration will cause stack corruption.
@@ -1247,7 +1247,7 @@ - (void)logMessage:(DDLogMessage *)logMessage {
v[2].iov_base = (char *)msg;
v[2].iov_len = msgLen;

if (_automaticallyAppendNewlineForCustomFormatters) {
if (iovec_len == 5) {
Copy link
Member

Choose a reason for hiding this comment

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

So _automaticallyAppendNewlineForCustomFormatters is now simply ignored?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is not ignored, _automaticallyAppendNewlineForCustomFormatters was checked a few lines above the diff context shown here (https://github.com/Marketcircle/CocoaLumberjack/blob/274842595742f649c5c67368c5f46584e4142688/Classes/DDTTYLogger.m#L1224). _automaticallyAppendNewlineForCustomFormatters was used to decide how large the io_vec should be.

Without this change, checking _automaticallyAppendNewlineForCustomFormatters again here causes a potential race condition if the property is changed from @NO to @YES.

Copy link
Member

Choose a reason for hiding this comment

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

I see.

rivera-ernesto pushed a commit that referenced this pull request Feb 2, 2015
Declare automaticallyAppendNewlineForCustomFormatters properties as nonatomic
@rivera-ernesto rivera-ernesto merged commit 5c8f2b7 into CocoaLumberjack:master Feb 2, 2015
@bpoplauschi bpoplauschi added this to the 2.0.0 milestone Feb 9, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants