Skip to content

Incremental compilation produces runtime crash #60706

Open
@mbrandonw

Description

@mbrandonw

Describe the bug

It is possible to make a program that when compiled and run works correctly, but then if a small change is made and run again it will consume a large amount of memory and then crash at runtime.

Further, if the target is cleaned and run again it works fine, which makes me think it is a bug with incremental compilation.

This happens in Swift 5.5-5.7 and perhaps earlier.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Open the demo project: incremental-bug.zip
  2. Navigate to Feature.swift
  3. Run the application and observe that it completes successfully.
  4. Uncomment the 3 lines in Feature.swift and run again.
  5. Observe that the application consume ~1.5GB of memory and then crashes.
  6. Clean the target (cmd+shift+K) and run again to observe that it completes successfully again.

Expected behavior
The application should not crash and should print the following to the console:

Sending .action1("Hello")
Running  action1("Hello")
Sending .action2
Running  action2

Environment (please fill out the following information)

  • OS: macOS 12.4 (21F79)
  • Xcode 13.2.1 (13C100) / Swift 5.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfincremental compilationswift 5.7

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions