Skip to content

[native-mt, 1.5.0-RC] Fix withTimeout throwing InvalidMutabilityException. #2689

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
May 13, 2021

Conversation

andersio
Copy link

@andersio andersio commented May 8, 2021

Resolves #2688.

TimeoutCoroutine subclasses ScopeCoroutine and adds a backing field time.

Since ScopeCoroutine may potentially freeze itself during its init block (by adding itself to a frozen job as a child), the init steps of TimeoutCoroutine as a subclass may consequentially fail, due to the object now potentially failing MutationCheck().

) : ScopeCoroutine<T>(uCont.context, uCont, false), Runnable {
init {
// Kludge for native
if (!isReuseSupportedInPlatform()) initParentForNativeUndispatchedCoroutine()
Copy link

@ArcticLampyrid ArcticLampyrid May 9, 2021

Choose a reason for hiding this comment

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

if (!isReuseSupportedInPlatform()) initParentForNativeUndispatchedCoroutine()

Personally, I prefer to make this as a initParentJob method in the superclass for maintainability

@andersio andersio force-pushed the anders/fix-withTimeout branch from 2314ea0 to fe2a5d3 Compare May 9, 2021 11:44
@andersio andersio force-pushed the anders/fix-withTimeout branch from fe2a5d3 to 95e5fb7 Compare May 9, 2021 11:57
@qwwdfsad qwwdfsad self-requested a review May 12, 2021 15:49
Copy link
Member

@qwwdfsad qwwdfsad left a comment

Choose a reason for hiding this comment

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

Great contribution, thanks for finding the root cause and the fix!

Hopefully we'll have a new memory-model soon and won't be needing to maintain such kludges

@qwwdfsad qwwdfsad merged commit 8108d32 into Kotlin:native-mt May 13, 2021
@andersio andersio deleted the anders/fix-withTimeout branch May 13, 2021 15:46
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.

3 participants