Skip to content

SwiftArena and invoking destroy on objects as arena is destroyed #67

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 18 commits into from
Oct 22, 2024

Conversation

ktoso
Copy link
Collaborator

@ktoso ktoso commented Oct 11, 2024

Work in progress.

This will eventually allow us to bound lifetimes with a SwiftArena and sanitize that we don't "leak" objects in native by retaining them longer than intended.

import org.swift.swiftkit.SwiftKit;

import org.swift.swiftkit.SwiftValueWitnessTable;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved some functionality out of SwiftKit, keeping it for things end users might wanna use.

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class SwiftRuntimeMetadataTest {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

made these into tests rather than just one off prints in main()

@ktoso ktoso requested a review from DougGregor October 11, 2024 15:57
@ktoso ktoso marked this pull request as draft October 11, 2024 15:57
@ktoso ktoso force-pushed the wip-arenas branch 4 times, most recently from 0ec066b to bb48895 Compare October 16, 2024 04:08
@ktoso ktoso changed the title [WIP] Work in progress on SwiftArena and invoking destroy on objects as arena is destroyed SwiftArena and invoking destroy on objects as arena is destroyed Oct 16, 2024
@ktoso ktoso marked this pull request as ready for review October 16, 2024 04:10
@ktoso
Copy link
Collaborator Author

ktoso commented Oct 16, 2024

Heh I don't understand why the Java/Linux crash, local linux build is happy. I'll have to revisit this later

@ktoso ktoso force-pushed the wip-arenas branch 2 times, most recently from 29225bc to aa988b1 Compare October 18, 2024 09:55
@ktoso
Copy link
Collaborator Author

ktoso commented Oct 18, 2024

Un-reproducible issues in CI which now manifest as hangs, quite a kerfuffle but I'll figure it out.

@ktoso
Copy link
Collaborator Author

ktoso commented Oct 20, 2024

So this reproduces only specifically in when running github actions, including using act so at least there's some hope to reproduce the issue. But it's pretty mysterious what's up with that.

@ktoso ktoso marked this pull request as draft October 22, 2024 04:43
@ktoso ktoso removed the request for review from DougGregor October 22, 2024 04:43
@ktoso
Copy link
Collaborator Author

ktoso commented Oct 22, 2024

Specifically x86 has some issue with the witness table call and we just hang on:

   java.lang.Thread.State: RUNNABLE
        at java.lang.invoke.LambdaForm$MH/0x00007f25c31e6400.invoke(java.base@22.0.2/LambdaForm$MH)
        at java.lang.invoke.LambdaForm$MH/0x00007f25c31e8800.invokeExact_MT(java.base@22.0.2/LambdaForm$MH)
        at jdk.internal.foreign.abi.DowncallStub/0x00007f25c31e6800.invoke(java.base@22.0.2/Unknown Source)
        at java.lang.invoke.LambdaForm$DMH/0x00007f25c31e6c00.invokeStaticInit(java.base@22.0.2/LambdaForm$DMH)
        at java.lang.invoke.LambdaForm$MH/0x00007f25c31e7c00.invoke(java.base@22.0.2/LambdaForm$MH)
        at java.lang.invoke.LambdaForm$MH/0x00007f25c31e8000.invokeExact_MT(java.base@22.0.2/LambdaForm$MH)
        at org.swift.swiftkit.SwiftValueWitnessTable.destroy(SwiftValueWitnessTable.java:221)
        at org.swift.swiftkit.SwiftHeapObjectCleanup.run(SwiftMemoryResourceCleanup.java:37)
        at org.swift.swiftkit.ConfinedSwiftMemorySession$ConfinedResourceList.cleanup(SwiftArena.java:140)
        at org.swift.swiftkit.ConfinedSwiftMemorySession.close(SwiftArena.java:104)
        at org.swift.swiftkit.SwiftArenaTest.arena_releaseClassOnClose_class_ok(SwiftArenaTest.java:50)

trying to debug on a linux amd64 host, we'll see if I can find out what's up

@ktoso ktoso marked this pull request as ready for review October 22, 2024 07:33
@ktoso
Copy link
Collaborator Author

ktoso commented Oct 22, 2024

I disabled the hanging test on x86_64 so we can revisit it, I don't have good ideas what might cause that right now. We'll have to dig deeper into it specifically. It's logged as: #97

Unblocking other progress by merging this for now though.

@ktoso ktoso merged commit bc54194 into swiftlang:main Oct 22, 2024
11 checks passed
@ktoso ktoso deleted the wip-arenas branch October 22, 2024 07:34
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.

1 participant