Skip to content

Fixes issue #4642: Encountering "Constant strings cannot be deallocated" in Linux foundation #4653

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

Merged
merged 1 commit into from
Nov 2, 2023

Conversation

dhoepfl
Copy link
Contributor

@dhoepfl dhoepfl commented Nov 3, 2022

Fixes issue #4642: Encountering "Constant strings cannot be deallocated" in Linux foundation

The reported error was an CFSTR("") which is later released. While this should not be a problem, the Linux implementation of CFSTR does not ignore dealloc on constant strings. Fixed this by calling CFRetain on the constant string.

Strictly speaking this is only a workaround. Issue #1351 has some hints how this could be fixed but the workaround is used a over the code so I think it is okay to use it here, too.

I found the same problem in CFDateIntervalFormatter.c where it appeared in a error handling code path that should never be called. Fixed anyways.

…deallocated" in Linux foundation

The reported error was an CFSTR("") which is later released. While this should
not be a problem, the Linux implementation of CFSTR does not ignore dealloc
on constant strings. Fixed this by calling CFRetain on the constant string.

Strictly speaking this is only a workaround. Issue swiftlang#1351 has some hints how
this could be fixed but the workaround is used a over the code so I think it
is okay to use it here, too.

I found the same problem in CFDateIntervalFormatter.c where it appeared in a
error handling code path that should never be called. Fixed anyways.
@MaxDesiatov
Copy link
Contributor

@swift-ci please test

@notcome
Copy link

notcome commented Nov 2, 2023

What can we do to get this one merged? I am starting to play around Swift server side and hit this issue when trying to load a resource from the module Bundle.

@parkera parkera merged commit 1c929e5 into swiftlang:main Nov 2, 2023
@parkera
Copy link
Contributor

parkera commented Nov 2, 2023

We can merge this. It does seem like a workaround, because plenty of other places CF will assume that CFSTR is constant.

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.

4 participants