-
-
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
RuntimeError and uninitialized/overwritten @State vars when using if
in View
view builder
#433
Comments
This does appear to be the same issue as #338. I get the error if the target is named |
You sure you're using the latest |
Ohh, I didn't anticipate that the names I gave to thing would influence whether this crash happens or not… I can confirm that when naming the target any of these, the crash will not occur:
Yes. I've compiled carton myself because I've not setup up Homebrew but I compiled it straight from the
I tried adding those linker flags but I haven't seen a change in behaviour (the tests above where I renamed the target were all done with those linker flags). I wasn't 100% sure I placed them in the right spot, look at the top of |
That's exactly what we were seeing with stack overflow issues.
Does setting bigger stack size help in any way? @kateinoigakukun would you be able to help? What would be the best way to diagnose this memory corruption issue if the SO sanitizer doesn't seem to be catching it? |
I couldn't find a way that made the problem go away, but different stack sizes lead to different error messages. Here are the min and max values I found that lead to each error message:
|
Looks like a bigger stack size makes it crash earlier. |
Describe the bug
I'm seeing crashes and other strange behavior on Wasm targets when trying to use a stateful view (using
@StateObject
) inside of anif
statement in aView
view builder.To Reproduce
I've tried all examples here with a single
main.swift
file, runningcarton dev
and loading the page in Chrome. The stack traces are copied out of Chrome's console.Running this example produces the following error:
Changing the declaration of
foo
to@State var foo: Int32 = 0
produces the following error:Changing the declaration of
foo
to@State var foo: Int64 = 0
produces the following error:Changing the declaration of
foo
back to@State var foo: Int32 = 0
and the declaration ofbody
tovar body: some View { Text("hello \(foo)") }
lets the application run without producing an error butfoo
will be initialized to16
instead of0
(theText
element will display "hello 16").Desktop (please complete the following information):
Additional context
Possibly related tickets: #222 #338
The text was updated successfully, but these errors were encountered: