Comments (10)
Have you any example that reproduce the problem?
from swiftjs.
I have google the error message. It seems that it is caused by the caller itself.
here is a example
vapor/fluent#487
you can store the JSContext with thread local variable.
from swiftjs.
Hi Susan,
Thank you for your response.
I've attached a sample program. After build & run, call the 'ink' example page a couple of times (i.e. curl localhost:8081/ink
). Eventually the application crashes. See also the attached screengrab (video).
I assume one reason for these crashes is the Vapor frameworks' inherent multithreaded/async architecture. The issue does not seem to happen when using the regular JavaScriptCore classes. Perhaps because the Swift wrapper in there is 'safer' than the C-function calls that use opaque pointers?
Thread Sanitizer did not provide any errors/warnings.
When running with Address Sanitizer turned on, I can't replicate the behavior.
Thanks again.
Cheers!
Maarten
https://user-images.githubusercontent.com/5150271/103753138-f2e63400-500a-11eb-91fc-5d47ad08dc3a.mp4
VaporInk.zip
from swiftjs.
The global variable var stories = [InkStory]()
in route.swift is the code causing the error.
swift array is not safe for mutation with multi-thread. That would destroy the array’s internal structure.
from swiftjs.
That's a plausible explanation. I've tried without the array and with just a local variable in the closure:
`
app.get("ink") { req -> String in
let inkStory: InkStory = {
let story = InkStory()
let storyJson = story.inkStoryJson(fileName: "Data/story.ink", fileExtension: "json")
story.loadStory(json: storyJson)
return story
}()
var result = inkStory.currentText + "\n"
while inkStory.canContinue {
result += inkStory.continueStory() + "\n"
print(inkStory.currentTags)
print(inkStory.options)
}
return result
}
`
Unfortunately, this also crashes. Tyically in JSVirtualMachine.swift
line 47 JSContextGroupRelease(group)
.
See also this movie:
Schermopname.2021-01-06.om.13.33.11.mp4
from swiftjs.
It’s seems to be bugs of JSC. I have test your code in my computer, and the execution isn’t in parallel.
I will try more tests later.
from swiftjs.
I minimize the app for testing first.
VaporInk.zip
you can also ask for help in apple’s forum. That may help to fix the bug if that’s the bug of JSC.
https://developer.apple.com/forums/tags/javascriptcore/
from swiftjs.
I submitted bug https://bugs.webkit.org/show_bug.cgi?id=220458 in the WebKit JavaScriptCore bug tracking system. I used your minimal project as an example.
from swiftjs.
bug has been fixed
076bbf0
it's no need to release the property name.
from swiftjs.
Cool! Just tested this and it works. Thanks for the fix!
from swiftjs.
Related Issues (2)
- Windows Support HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swiftjs.