Open jpsim opened 8 years ago
As I tested, debug build of sourcekitten crashed. But release build of sourcekitten did not crash.
I tested the file you provided, and interestingly, it worked. However, I have to make it a lot better as it is now used in many good projects like yours. I'm working on something a lot better.
As with most stack overflow issues, this will depend on your environment, so it's entirely possible the exact file linked to above didn't trigger one for you. You might need to experiment with larger structures to hit this.
I replicated your file 4 times under another keys to make it bigger and it loaded successfully, although it took a long time.
As I said, I'm working on something completely different. Hope I can put enough time on it.
Sounds great, though as we discovered in jpsim/SourceKitten#211, I can't reproduce this when compiling Swift with optimizations, so it's not a pressing issue on my end.
Can you please test again with parsec branch?
I can't speak to the stack overflow yet, I think that's resolved. But the performance is both considerably better on Linux and considerably worse on macOS: jpsim/SourceKitten#289
@jpsim Does this still happen on the Swift 4 branch?
Looks like the recursive nature of the parser makes it quite susceptible to stack overflows when parsing larger yaml structures. Not that ~500 lines is that large for a yaml file...
You can reproduce this by
Yaml.load
ing this file, which causes a stack overflow on my mac (see this backtrace of ~900 YamlSwift stack frames).I'm not familiar enough with the algorithm used here to avoid the recursion, which seems to be the only way to truly avoid this issue. Quite interested in hearing your thoughts @behrang!