-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
Infinite loops w/ 100% CPU usage caused by stack overflows #367
Comments
I've been sticking @kateinoigakukun please help, my debugging skills are not good enough for this. My only hypothesis is that something's weird with the metadata (maybe the Runtime library misreads some fields?) and this somehow messes everything up. |
Also, I've verified that this is reproducible in both |
We had some issues in this code area previously and I'm thinking of refactoring it in attempt to fix #367. Would be great to increase the test coverage here before further refactoring.
This should allow us to remove the Runtime dependency eventually, which seems to be unstable, especially across different platforms and Swift versions. Seems to resolve in one instance #367. There are a few other places where `typeInfo` is still used, I'll clean that up in a follow-up PR. * Replace uses of the Runtime library with stdlib * Remove irrelevant Runtime library imports * Add TokamakCoreBenchmark target
* Add a test for environment injection We had some issues in this code area previously and I'm thinking of refactoring it in attempt to fix #367. Would be great to increase the test coverage here before further refactoring. * Update copyright years in `MountedElement.swift` * Update copyright years in the rest of the files
Our OpenCombine fork no longer depends on Runtime, and we don't need much from it other than struct metadata. I removed the unused bits and bobs and kept only a minimal subset of it that we really need. This should make it easier for us to test and debug, as #367 has shown that some weird stuff may still lurk in that area. * Add a test for environment injection We had some issues in this code area previously and I'm thinking of refactoring it in attempt to fix #367. Would be great to increase the test coverage here before further refactoring. * Update copyright years in `MountedElement.swift` * Update copyright years in the rest of the files * Vend the Runtime library directly * Remove unused class, enum, tuple, func reflection * Remove unused models and protocol metadata * Remove unused MetadataType and NominalMetadataType * Remove unused protocols, rename RelativePointer * Remove more unused protocols * Use immutable pointers for reflection * Update copyright headers
Reopening, as this issue is still reproducible in Thanks to @foscomputerservices for uncovering this! |
I've pushed the changes to a branch if anyone's interested in reproducing it on their side. |
TWIMC, all points to this being a stack overflow issue, the immediate workaround is to add these flags to your linkerSettings: [
.unsafeFlags(["-Xlinker", "--stack-first", "-Xlinker", "-z", "-Xlinker", "stack-size=16777216"]),
] The required stack size may be bigger to accommodate for bigger view hierarchies. The most probable long-term fix will probably require Tokamak to allocate some more on the heap. As @kateinoigakukun said:
|
This solves the issues that I was having. Thank you for all of your efforts! |
Had a question asked about it, wanted to clarify that |
We have a sanitizer shipped and enabled by default for debug builds in |
Most of the changes are related to the use of OpenCombineShim (available in upstream OpenCombine now) instead of CombineShim. But there is also a new test added during the investigation of #367, where an app is rendered end-to end, which is a good way to expand our test suite I think. * Use immediate scheduler in TestRenderer This allows running our test suite on WASI too, which doesn't have Dispatch and also can't wait on XCTest expectations. Previously none of our tests (especially runtime reflection tests) ran on WASI. * Run `carton test` and `carton bundle` in separate jobs * Bump year in the `LICENSE` file * Add reconciler stress tests for elaborate testing * Move default App implementation to TestRenderer * Use OpenCombineShim instead of CombineShim
Hey wait I just had this issue! I was getting it when an ObservableObject was subscribed to an Electron IPC listener and was making @published updates. The 100% CPU on the renderer process only showed up when the chromium window became completely occluded, strangely. Anyway, using the aforementioned flags worked for me: linkerSettings: [
.unsafeFlags(["-Xlinker", "--stack-first", "-Xlinker", "-z", "-Xlinker", "stack-size=16777216"], .when(platforms: [.wasi]),
] |
Describe the bug
There's a certain snippet of code, which when rendererd in the browser triggers an infinite loop after clicking on a
NavigationLink
.To Reproduce
Build and run this snippet with
carton dev
:Open it in any browser a tap on "Item 1". Sometimes it loads the destination, but frequently it just hangs. If it doesn't hang, reload the page and try again. It's usually reproducible at least one in five attempts. I've reproduced in Safari, Firefox, and Chrome.
Expected behavior
NavigationLink
always opens the destination without any problems.Screenshots
![Screenshot 2021-01-21 at 20 22 35](https://user-images.githubusercontent.com/112310/105408078-6a7cab80-5c26-11eb-92e7-e0f5eb0d2738.png)
Additional context
This was reported by @foscomputerservices in a bigger project, but I've managed to reduce it to this snippet. I've tried to remove seemingly unrelated modifiers or views, like
listStyle
orpadding
, but removing them seems to make the issue go away or reduce the probability or reproduction steps to something I can't trigger anymore.The text was updated successfully, but these errors were encountered: