Introducing property wrappers to a project breaks compiler (infinite execution)

Hello,

I've been trying to implement property wrappers in one of my existing projects today. I have generic class Serialized which ensures, that all getters and setters of the property are executed on specific thread.

By the time I modified almost all instances of the class to conform to the new interface, the swift compiler stopped working.

Specifically when I initiate build it launches a process called "swift" that takes 95% - 100% of cpu time (of one core). When I abort build, compiler may or may not report non-zero status, but the "swift" process never stops. Whenever I initiate a new build, new "swift" process begins. I had 6 instances of the "swift" at one point. Those processes don't stop until I reboot my mac.

Is there a way to get some meaningful reason why the compiler misbehaves?

Thanks, Mikolas

The best thing I could suggest, is to try and get a minimal project that exhibit the same behavior, isolating the cause. Since you just added property wrapper, that’s likely the culprit. Maybe you can create a new project with the said property wrapper and the use site and see if it’s still taking a long time (and more importantly, can’t be stopped).

That’d help both you (to know what to avoid in the meantime and find workaround), and the compiler engineers (to get a testable scenario).

My gut reaction would be on type checking, but who knows.

Thanks for reply.

This (brute force) method may take a lot of time, since every few times I run the process I need to restart my Mac.
I may attempt to do it later (at the weekend maybe) and let you know of the results.

This is not the first time I've tried property wrapped. I've been playing with them on Ubuntu before 5.1 was released. I have never experienced such a problem before. That's why I'm asking here. Without any response from compiler it's hard for me to isolate the line of code or the pattern causing the issue.

Likely not your fault, compiler shouldn’t straight up freezing (or crashing) like that. Does it not even response to SIGKILL?

Well, it does, but SourceKitService is also affected and killing all of "swift" instances and the SourceKitService breaks Xcode. Therefore I restart mac.

1 Like

Please file a bug at bugs.swift.org with your project or a small reproducer. If your project is private and you don't want to share it publicly, you can file a Feedback and attach the project.