Crash getting creation date from url / file manager (when file is > 2gb)

Hello all,

I've spent all day beating my head against a crash in my windows build of this cross platform app. Here's the problem line:

 let values = try url.resourceValues(forKeys: [.nameKey, .creationDateKey, .contentModificationDateKey])

It's specifically related to the creationDate or modificationDate keys. Checking for either one leads to a crash in swiftCore.dll... but here's the kicker - it only happens for files larger than 2gb?

Is there any way to symbolize swiftCore and Foundation? I'm using sentry to capture these crash reports, but I dont have symbols for much in this backtrace:

Thread 11216 Crashed:
0   Foundation.dll                  0x7fff5d06af41      <unknown>
1   swiftCore.dll                   0x7fff6fd9b630      <unknown>
2   Foundation.dll                  0x7fff5d05939c      <unknown>
3   swiftCore.dll                   0x7fff6fb73490      <unknown>
4   swiftCore.dll                   0x7fff6fdb9c00      <unknown>
5   swiftCore.dll                   0x7fff6fa473bb      <unknown>
6   swiftCore.dll                   0x7fff6fd9b630      <unknown>
7   swiftCore.dll                   0x7fff6fb751ff      <unknown>
8   swiftCore.dll                   0x7fff6fc14004      <unknown>
9   swiftCore.dll                   0x7fff6fb73506      <unknown>
10  swiftCore.dll                   0x7fff6fb59ac9      <unknown>
11  Foundation.dll                  0x7fff5d065ef0      <unknown>
12  swiftCore.dll                   0x7fff6f87847c      <unknown>
13  Foundation.dll                  0x7fff5d5a1c80      <unknown>
14  Foundation.dll                  0x7fff5d5a1c60      <unknown>
15  swiftCore.dll                   0x7fff6f96bcdb      <unknown>
16  Foundation.dll                  0x7fff5d1ce595      <unknown>
17  swiftCore.dll                   0x7fff6fb73003      <unknown>
18  Foundation.dll                  0x7fff5d1ce62b      <unknown>
19  swiftCore.dll                   0x7fff6fbb5f10      <unknown>
20  swiftCore.dll                   0x7fff6f96bbbb      <unknown>
21  swiftCore.dll                   0x7fff6fbfd0c5      <unknown>
22  Foundation.dll                  0x7fff5d271496      <unknown>
23  swiftCore.dll                   0x7fff6fa57cd0      <unknown>
24  swiftCore.dll                   0x7fff6fbb5f10      <unknown>
25  Foundation.dll                  0x7fff5d5a0e58      <unknown>
26  swiftCore.dll                   0x7fff6fa57cd0      <unknown>
27  Foundation.dll                  0x7fff5d1d19c6      <unknown>
28  ucrtbase.dll                    0x7fffdd4d364a      free_base
29  swiftCore.dll                   0x7fff6fb751ff      <unknown>
30  swiftCore.dll                   0x7fff6fd9b630      <unknown>
31  swiftCore.dll                   0x7fff6fc1a7a0      <unknown>
32  swiftCore.dll                   0x7fff6fdb9c28      <unknown>
33  swiftCore.dll                   0x7fff6fd9b630      <unknown>
34  swiftCore.dll                   0x7fff6fc1a7a0      <unknown>
35  swiftCore.dll                   0x7fff6fc29c00      <unknown>
36  Foundation.dll                  0x7fff5d1c9120      <unknown>
37  swiftCore.dll                   0x7fff6fd9b610      <unknown>
38  swiftCore.dll                   0x7fff6fb73003      <unknown>
39  swiftCore.dll                   0x7fff6fb74090      <unknown>
40  ntdll.dll                       0x7fffe01c3baf      RtlAddRefActivationContext
41  Foundation.dll                  0x7fff5d171259      <unknown>
42  swiftCore.dll                   0x7fff6fd9b610      <unknown>
43  Foundation.dll                  0x7fff5d170209      <unknown>
44  swiftCore.dll                   0x7fff6fb74090      <unknown>
45  swiftCore.dll                   0x7fff6fc29b28      <unknown>
46  Foundation.dll                  0x7fff5d1cae7d      <unknown>
47  Foundation.dll                  0x7fff5d2f88e4      <unknown>
48  swiftCore.dll                   0x7fff6fbb5f10      <unknown>
49  Foundation.dll                  0x7fff5d1c72a7      <unknown>
50  swiftCore.dll                   0x7fff6fd9b630      <unknown>
51  swiftCore.dll                   0x7fff6fb73ef0      <unknown>
52  swiftCore.dll                   0x7fff6fbb5f10      <unknown>
53  Foundation.dll                  0x7fff5d1ca396      <unknown>
54  Foundation.dll                  0x7fff5d2648ab      <unknown>
55  swiftCore.dll                   0x7fff6fbb5f10      <unknown>
56  swiftCore.dll                   0x7fff6fd9b610      <unknown>
57  swiftCore.dll                   0x7fff6fbb5f70      <unknown>
58  swiftCore.dll                   0x7fff6fb73ef0      <unknown>
59  Test.exe                      0x7ff75a52a840      TestFileMetadataReader.getMetadataFromURL (TestFileMetadataReader.swift:18)

I confirmed this is file size related by taking a failing 3gb file and calling

fsutil file seteof <filename> 2147483647

and the file works... truncating a single byte larger fails.

The similar api in FileManager fails in the same way.

mike

Oh man, just came here to see if anyone else had this problem… Did you ever figure anything out? @compnerd any ideas on how to get better debug information so we can make a PR and get this fixed?

Just to be clear: Swift 6.1.2 - I haven’t had a chance to check main or release/6.2 latest yet…

I would say that you would need to build Foundation with debug info to get a better stack trace to figure out what is happening. This should be a little bit easier now with the new Foundation package. I imagine that you could do some hacks with -nostdlibimport to ensure that your local Foundation build is used.

1 Like

It’s actually a nightmarish problem.

Whenever resourceValues-based APIs touch a >2GB file it’s an instant crash. For example, this crash happens when I try to enumerate all the files in a folder using FileManager enumerate APIs.

0x0000009e1511b3, Main.dll!
0x00000073753dc6, ntdll.dll!RtlWow64GetCurrentCpuArea
0x00000073754326, ntdll.dll!RtlWow64GetCurrentCpuArea
0x0000007384692e, ntdll.dll!KiUserExceptionDispatcher
0x00000086e38f64, Foundation.dll!type metadata accessor for (extension in Foundation):FoundationEssentials.FileManager.DirectoryEnumerator
0x00000086e33f36, Foundation.dll!(extension in Foundation):FoundationEssentials.FileManager.getRelationship(_: Swift.UnsafeMutablePointer<FoundationEssentials.FileManager.URLRelationship>, of: FoundationEssentials.FileManager.SearchPathDirectory, in: FoundationEssentials.FileManager.SearchPathDomainMask, toItemAt: FoundationEssentials.URL) throws -> ()
0x00000086f354ed, Foundation.dll!Foundation.NSURL.resolvingSymlinksInPath.getter : Swift.Optional<FoundationEssentials.URL>
0x00000086f36e80, Foundation.dll!type metadata accessor for Foundation.NSURL
0x00000086f327b2, Foundation.dll!Foundation.NSURL.__allocating_init() -> Foundation.NSURL
0x00000086f31e27, Foundation.dll!Foundation.NSURL.resourceValues(forKeys: Swift.Array<Foundation.URLResourceKey>) throws -> Swift.Dictionary<Foundation.URLResourceKey, Any>
0x00000086fa5108, Foundation.dll!(extension in Foundation):FoundationEssentials.URL.resourceValues(forKeys: Swift.Set<Foundation.URLResourceKey>) throws -> Foundation.URLResourceValues
0x0000009e2838f6, Main.dll!(extension in Foundation):FoundationEssentials.URL.resourceValues(forKeys: Swift.Set<Foundation.URLResourceKey>) throws -> Foundation.URLResourceValues
0x0000009e28365c, Main.dll!(extension in Foundation):FoundationEssentials.URL.resourceValues(forKeys: Swift.Set<Foundation.URLResourceKey>) throws -> Foundation.URLResourceValues
0x0000009e283335, Main.dll!(extension in Foundation):FoundationEssentials.URL.resourceValues(forKeys: Swift.Set<Foundation.URLResourceKey>) throws -> Foundation.URLResourceValues