Skip to content

SelectDeadlockLFStressTest.testLockFreedom fails with KNPE #1561

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

Closed
elizarov opened this issue Sep 22, 2019 · 0 comments
Closed

SelectDeadlockLFStressTest.testLockFreedom fails with KNPE #1561

elizarov opened this issue Sep 22, 2019 · 0 comments
Assignees
Labels

Comments

@elizarov
Copy link
Contributor

See https://teamcity.jetbrains.com/viewLog.html?buildId=2544504&buildTypeId=KotlinTools_KotlinxCoroutines_NightlyStressWindows

Test SelectDeadlockLFStressTest.testLockFreedom:

kotlin.KotlinNullPointerException
	at kotlinx.coroutines.channels.AbstractSendChannel.offerSelectInternal(AbstractChannel.kt:68)
	at kotlinx.coroutines.channels.AbstractSendChannel.registerSelectSend(AbstractChannel.kt:400)
	at kotlinx.coroutines.channels.AbstractSendChannel.access$registerSelectSend(AbstractChannel.kt:18)
	at kotlinx.coroutines.channels.AbstractSendChannel$onSend$1.registerSelectClause2(AbstractChannel.kt:378)
	at kotlinx.coroutines.selects.SelectBuilderImpl.invoke(Select.kt:618)
	at kotlinx.coroutines.selects.SelectDeadlockLFStressTest$TestDef.sendClause(SelectDeadlockLFStressTest.kt:88)
	at kotlinx.coroutines.selects.SelectDeadlockLFStressTest$TestDef.access$sendClause(SelectDeadlockLFStressTest.kt:49)
	at kotlinx.coroutines.selects.SelectDeadlockLFStressTest$TestDef$$special$$inlined$apply$lambda$1.invoke(SelectDeadlockLFStressTest.kt:65)
	at kotlinx.coroutines.selects.SelectDeadlockLFStressTest$TestDef$$special$$inlined$apply$lambda$1.invoke(SelectDeadlockLFStressTest.kt:49)
	at kotlinx.coroutines.selects.SelectDeadlockLFStressTest$TestDef.doSendReceive(SelectDeadlockLFStressTest.kt:80)
	at kotlinx.coroutines.selects.SelectDeadlockLFStressTest$TestDef$test$1.invokeSuspend(SelectDeadlockLFStressTest.kt:74)
	at kotlinx.coroutines.selects.SelectDeadlockLFStressTest$TestDef$test$1.invoke(SelectDeadlockLFStressTest.kt)
	at kotlinx.atomicfu.LockFreedomTestEnvironment$TestThread.callOperation(LockFreedomTestEnvironment.kt:294)
	at kotlinx.atomicfu.LockFreedomTestEnvironment$TestThread.run(LockFreedomTestEnvironment.kt:223)
@elizarov elizarov added the bug label Sep 22, 2019
@elizarov elizarov self-assigned this Sep 22, 2019
elizarov added a commit that referenced this issue Sep 22, 2019
This bug was introduced by #1524. The crux of problem is that
TryOffer/PollDesc.onPrepare method is no longer allowed to update
fields in these classes (like "resumeToken" and "pollResult") after call
to tryResumeSend/Receive method, because the latter will complete
the ongoing atomic operation and helper method might find it complete
and try reading "resumeToken" which was not initialized yet.

This change removes "pollResult" field which was not really needed
("result.pollResult" field is used) and removes "resumeToken" by
exploiting the fact that current implementation of
CancellableContinuationImpl does not need a token anymore. However,
CancellableContinuation.tryResume/completeResume ABI is left intact,
because it is used by 3rd party code.

This fix lead to overall simplification of the code. A number of fields
and an auxiliary IdempotentTokenValue class are removed, tokens used to
indicate various results are consolidated, so that resume success
is now consistently indicated by a single RESUME_TOKEN symbol.

Fixes #1561
elizarov added a commit that referenced this issue Sep 23, 2019
This bug was introduced by #1524. The crux of problem is that
TryOffer/PollDesc.onPrepare method is no longer allowed to update
fields in these classes (like "resumeToken" and "pollResult") after call
to tryResumeSend/Receive method, because the latter will complete
the ongoing atomic operation and helper method might find it complete
and try reading "resumeToken" which was not initialized yet.

This change removes "pollResult" field which was not really needed
("result.pollResult" field is used) and removes "resumeToken" by
exploiting the fact that current implementation of
CancellableContinuationImpl does not need a token anymore. However,
CancellableContinuation.tryResume/completeResume ABI is left intact,
because it is used by 3rd party code.

This fix lead to overall simplification of the code. A number of fields
and an auxiliary IdempotentTokenValue class are removed, tokens used to
indicate various results are consolidated, so that resume success
is now consistently indicated by a single RESUME_TOKEN symbol.

Fixes #1561
elizarov added a commit that referenced this issue Sep 23, 2019
This bug was introduced by #1524. The crux of problem is that
TryOffer/PollDesc.onPrepare method is no longer allowed to update
fields in these classes (like "resumeToken" and "pollResult") after call
to tryResumeSend/Receive method, because the latter will complete
the ongoing atomic operation and helper method might find it complete
and try reading "resumeToken" which was not initialized yet.

This change removes "pollResult" field which was not really needed
("result.pollResult" field is used) and removes "resumeToken" by
exploiting the fact that current implementation of
CancellableContinuationImpl does not need a token anymore. However,
CancellableContinuation.tryResume/completeResume ABI is left intact,
because it is used by 3rd party code.

This fix lead to overall simplification of the code. A number of fields
and an auxiliary IdempotentTokenValue class are removed, tokens used to
indicate various results are consolidated, so that resume success
is now consistently indicated by a single RESUME_TOKEN symbol.

Fixes #1561
elizarov added a commit that referenced this issue Sep 26, 2019
This bug was introduced by #1524. The crux of problem is that
TryOffer/PollDesc.onPrepare method is no longer allowed to update
fields in these classes (like "resumeToken" and "pollResult") after call
to tryResumeSend/Receive method, because the latter will complete
the ongoing atomic operation and helper method might find it complete
and try reading "resumeToken" which was not initialized yet.

This change removes "pollResult" field which was not really needed
("result.pollResult" field is used) and removes "resumeToken" by
exploiting the fact that current implementation of
CancellableContinuationImpl does not need a token anymore. However,
CancellableContinuation.tryResume/completeResume ABI is left intact,
because it is used by 3rd party code.

This fix lead to overall simplification of the code. A number of fields
and an auxiliary IdempotentTokenValue class are removed, tokens used to
indicate various results are consolidated, so that resume success
is now consistently indicated by a single RESUME_TOKEN symbol.

Fixes #1561
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant