-
Notifications
You must be signed in to change notification settings - Fork 143
Fixed stack overflow during execution of MacroEvaluationProgram #997
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
Conversation
|
@jakepetroules can you please run CI tests? I don't have permission for that. Thanks in advance! |
|
@swift-ci please test |
|
@swift-ci test |
owenv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one small comment, otherwise this change lgtm
|
@owenv Thanks for review! I've fixed your comment |
|
@swift-ci test |
|
@owenv the Swift Test macOS Platform (Swift main) failed with following assertation: It doesn't seem, that it's connected with that PR |
|
@swift-ci test macOS |
|
Pull request / Test / Swift SDK for Android Build (nightly-main - noble - NDK r27d) (pull_request) failed with |
|
that's a known issue in the android job, we can merge this |
During the migration of a large project (~1800 targets) to a new version of Xcode, we faced constant build system crashes.
The first crash occurred during recursive
lookupMacroDeclarationandlookupConditionParameterevaluation, which is being fixed in #992.A second crash appeared in multiple places but always reduced to
MacroEvaluationProgram.executeInContext. Evaluating the instructionevalNamedMacroand then callingvalue.expression.evaluate(context:resultBuilder:alwaysEvalAsString)blew the call stack.This PR converts that recursive evaluation of the value expression to a stack-based approach that can handle any depth.
Each frame on the stack represents an in-progress evaluation of a macro expression. When we need to evaluate a nested macro, instead of making a recursive call, we push the current state onto the stack and start evaluating the nested expression. When we complete an expression evaluation, we pop the stack and continue.
This fix, combined with the one in #992, resolves the issue described in https://forums.swift.org/t/xcode-15-3-xcbuildservice-crash-infinite-loop-when-building-ios-project/70643/7.