malcommac / SwiftDate

🐔 Toolkit to parse, validate, manipulate, compare and display dates, time & timezones in Swift.
MIT License
7.61k stars 767 forks source link

toRelative formatter crashes with EXC_BAD_INSTRUCTION #797

Open creativecbr opened 2 years ago

creativecbr commented 2 years ago

I faced problem as in title, when I call .toRelative(since:style:locale:) on my date which as string is f.e. "2022-06-07 13:12:06 +0000" my app crashes. Crash stack from Console app prints:

Thread 0 Crashed::  Dispatch queue: com.apple.main-thread
0   SwiftDate                              0x10425f4ee specialized static RelativeFormatter.suitableFlavour(inList:forLocale:) + 1230
1   SwiftDate                              0x10425e46d specialized static RelativeFormatter.format(date:to:style:locale:) + 1517
2   SwiftDate                              0x104252e9b DateRepresentable.toRelative(since:style:locale:) + 507
3   MyApp                              0x103f8d8cf 0x103f76000 + 96463

The line where I call that is the last one below:

 var locales = Locales.english
 let style = RelativeFormatter.timeStyle()
 return creationDate.toRelative(style:style, locale: locales)

Maybe is significant that I call that in SwiftUI.

The problem occurs after a few launches on OS X 10.15 and 12.4 at this moment, architecture x86_64.

The error is:


System Integrity Protection: enabled

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes:       0x0000000000000001, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Termination Reason:    Namespace SIGNAL, Code 4 Illegal instruction: 4
Terminating Process:   exc handler [830]

Thanks for every help!

wonder2011 commented 2 years ago

Can u provide the code where this is happening, your own code ?