stripe / stripe-ios

Stripe iOS SDK
https://stripe.com
MIT License
2.12k stars 981 forks source link

[BUG] Crash in DocumentUploader+API.swift #3193

Open danielgarbien opened 9 months ago

danielgarbien commented 9 months ago

Summary

App crashes.

Code to reproduce

N/A

iOS version

Seen on iOS 15.4.1 and 17.2.1

Installation method

SPM

SDK version

23.20.0

Other information

SIGTRAP (#0): Application crash: SIGTRAP (Trace/BPT trap)
0   XXXModules                      0x000000010f4a8ffc Swift runtime failure: Double value cannot be converted to Int because it is either infinite or NaN + 0
1   XXXModules                      0x000000010f4a8ffc closure #3 (CameraSession.DeviceProperties) in StripeAPI.VerificationPageDataDocumentFileData.init(documentScannerOutput: DocumentScannerOutput?, highResImage: String, lowResImage: String?, exifMetadata: CameraExifMetadata?, uploadMethod: StripeAPI.VerificationPageDataDocumentFileData.FileUploadMethod, forceConfirm: Bool) + 1252 (DocumentUploader+API.swift:44)
2   XXXModules                      0x000000010f4a8ffc specialized Optional.map<A>((A)) + 1308
3   XXXModules                      0x000000010f4a8ffc specialized StripeAPI.VerificationPageDataDocumentFileData.init(documentScannerOutput: DocumentScannerOutput?, highResImage: String, lowResImage: String?, exifMetadata: CameraExifMetadata?, uploadMethod: StripeAPI.VerificationPageDataDocumentFileData.FileUploadMethod, forceConfirm: Bool) + 1656 (DocumentUploader+API.swift:43)
4   XXXModules                      0x000000010f4f258c closure #1 (StripeFile, StripeFile) in DocumentUploader.uploadImages(_: CGImageRef, documentScannerOutput: DocumentScannerOutput?, exifMetadata: CameraExifMetadata?, method: StripeAPI.VerificationPageDataDocumentFileData.FileUploadMethod, fileNamePrefix: String) + 176 (DocumentUploader.swift:192)
5   XXXModules                      0x000000010f4f2cd4 partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed StripeFile, @in_guaranteed StripeFile) -> (@owned Future<StripeAPI.VerificationPageDataDocumentFileData>, @error @owned Error) + 60
6   XXXModules                      0x000000010f272870 closure #1 (Result<A, Error>) in Future.chained<A>(on: OS_dispatch_queue?, using: (A)) + 268 (Async.swift:88)
7   XXXModules                      0x000000010f27327c partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A, Error>) -> () + 20
8   XXXModules                      0x000000010f27351c partial apply for closure #1 ((Result<A, Error>)) in Future.report(result: Result<A, Error>) + 32
9   libswiftCore.dylib                  0x000000018d726538 Sequence.forEach((A.Element)) + 740
10  XXXModules                      0x000000010f27266c Future.report(result: Result<A, Error>) + 208 (Async.swift:69)
11  XXXModules                      0x000000010f273540 partial apply for thunk for @callee_guaranteed (@in_guaranteed Result<A, Error>) -> (@error @owned Error) + 20
12  libswiftCore.dylib                  0x000000018d672b68 Optional.map<A>((A)) + 508
13  XXXModules                      0x000000010f271fdc Future.result.didset + 240 (Async.swift:41)
14  XXXModules                      0x000000010f273230 specialized Future.result.setter + 140
15  XXXModules                      0x000000010f272d80 Future.result.setter + 8
16  XXXModules                      0x000000010f272d80 Promise.resolve(with: A) + 220 (Async.swift:135)
17  XXXModules                      0x000000010f272a14 closure #1 (Result<A1, Error>) in closure #1 (Result<A, Error>) in Future.chained<A>(on: OS_dispatch_queue?, using: (A)) + 252 (Async.swift:95)
18  XXXModules                      0x000000010f27327c partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A, Error>) -> () + 20
19  XXXModules                      0x000000010f27351c partial apply for closure #1 ((Result<A, Error>)) in Future.report(result: Result<A, Error>) + 32
20  libswiftCore.dylib                  0x000000018d726538 Sequence.forEach((A.Element)) + 740
21  XXXModules                      0x000000010f27266c Future.report(result: Result<A, Error>) + 208 (Async.swift:69)
22  XXXModules                      0x000000010f273540 partial apply for thunk for @callee_guaranteed (@in_guaranteed Result<A, Error>) -> (@error @owned Error) + 20
23  libswiftCore.dylib                  0x000000018d672b68 Optional.map<A>((A)) + 508
24  XXXModules                      0x000000010f271fdc Future.result.didset + 240 (Async.swift:41)
25  XXXModules                      0x000000010f273230 specialized Future.result.setter + 140
26  XXXModules                      0x000000010f272d80 Future.result.setter + 8
27  XXXModules                      0x000000010f272d80 Promise.resolve(with: A) + 220 (Async.swift:135)
28  XXXModules                      0x000000010f272a14 closure #1 (Result<A1, Error>) in closure #1 (Result<A, Error>) in Future.chained<A>(on: OS_dispatch_queue?, using: (A)) + 252 (Async.swift:95)
29  XXXModules                      0x000000010f2722d8 Future.observe(on: OS_dispatch_queue?, using: (Result<A, Error>)) + 568 (Async.swift:62)
30  XXXModules                      0x000000010f2728d8 closure #1 (Result<A, Error>) in Future.chained<A>(on: OS_dispatch_queue?, using: (A)) + 372 (Async.swift:92)
31  XXXModules                      0x000000010f27327c partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A, Error>) -> () + 20
32  XXXModules                      0x000000010f27351c partial apply for closure #1 ((Result<A, Error>)) in Future.report(result: Result<A, Error>) + 32
33  libswiftCore.dylib                  0x000000018d726538 Sequence.forEach((A.Element)) + 740
34  XXXModules                      0x000000010f27266c Future.report(result: Result<A, Error>) + 208 (Async.swift:69)
35  XXXModules                      0x000000010f273540 partial apply for thunk for @callee_guaranteed (@in_guaranteed Result<A, Error>) -> (@error @owned Error) + 20
36  libswiftCore.dylib                  0x000000018d672b68 Optional.map<A>((A)) + 508
37  XXXModules                      0x000000010f271fdc Future.result.didset + 240 (Async.swift:41)
38  XXXModules                      0x000000010f273230 specialized Future.result.setter + 140
39  XXXModules                      0x000000010f272f68 Future.result.setter + 8
40  XXXModules                      0x000000010f272f68 Promise.fullfill(with: Result<A, Error>) + 200 (Async.swift:143)
41  XXXModules                      0x000000010f4f3984 $s14StripeIdentity0B13ImageUploaderC10uploadJPEG5image8fileName22jpegCompressionQuality0A4Core6FutureCyAH0A4FileVGSo10CGImageRefa_SS0M8Graphics7CGFloatVtFyyYbcfU_ys6ResultOyAL0H0_AH12STPAPIClientC0C13UploadMetricsV7metricsts5Error_pGcfU_ + 576 (IdentityImageUploader.swift:156)
42  XXXModules                      0x000000010f27327c partial apply for thunk for @escaping @callee_guaranteed (@in_guaranteed Result<A, Error>) -> () + 20
43  XXXModules                      0x000000010f2739cc specialized implicit closure #2 (Result<A, Error>) in implicit closure #1 (Future<A>) in Future.result.didset + 108
44  XXXModules                      0x000000010f232388 specialized Optional.map<A>((A)) + 248
45  XXXModules                      0x000000010f232ce4 specialized Promise.fullfill(with: Result<A, Error>) + 244 (Async.swift:143)
46  XXXModules                      0x000000010f232ce4 closure #1 (Result<(file: StripeFile, metrics: STPAPIClient.ImageUploadMetrics), Error>) in STPAPIClient.uploadImageAndGetMetrics(_: UIImage, compressionQuality: CGFloat, purpose: String, fileName: String, ownedBy: String?, ephemeralKeySecret: String?) + 276 (STPAPIClient+FileUpload.swift:227)
47  XXXModules                      0x000000010f232660 closure #3 (Result<StripeFile, Error>) in STPAPIClient.uploadImageAndGetMetrics(_: UIImage, compressionQuality: CGFloat, purpose: String, fileName: String, ownedBy: String?, ephemeralKeySecret: String?, completion: (Result<(file: StripeFile, metrics: STPAPIClient.ImageUploadMetrics), Error>)) + 656 (STPAPIClient+FileUpload.swift:164)
48  XXXModules                      0x000000010f232ff4 $s10StripeCore12STPAPIClientC11sendRequest7request10completiony10Foundation10URLRequestV_ys6ResultOyxs5Error_pGctSeRzlFyAG4DataVSg_So13NSURLResponseCSgsAL_pSgtcfU_yyScMYccfU_AA0A4FileV_Tg5 + 160
49  XXXModules                      0x000000010f23b390 thunk for @escaping @callee_guaranteed () -> () + 28
50  libdispatch.dylib                   0x000000019c27b6a8 _dispatch_call_block_and_release + 32
51  libdispatch.dylib                   0x000000019c27d300 _dispatch_client_callout + 20
52  libdispatch.dylib                   0x000000019c28b998 _dispatch_main_queue_drain + 984
53  libdispatch.dylib                   0x000000019c28b5b0 _dispatch_main_queue_callback_4CF + 44
54  CoreFoundation                      0x00000001942bd01c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
55  CoreFoundation                      0x00000001942b9d28 __CFRunLoopRun + 1996
56  CoreFoundation                      0x00000001942b9478 CFRunLoopRunSpecific + 608
57  GraphicsServices                    0x00000001d783a4f8 GSEventRunModal + 164
58  UIKitCore                           0x00000001966dd62c -[UIApplication _run] + 888
59  UIKitCore                           0x00000001966dcc68 UIApplicationMain + 340
60  UIKitCore                           0x00000001969073d0 __swift_destroy_boxed_opaque_existential_1Tm + 12220
61  XXX                             0x0000000104e68138 specialized static UIApplicationDelegate.main() + 112
62  XXX                             0x0000000104e68098 main + 24
annie-gupta commented 9 months ago

Can you please assign this issue to me? I would like to look into this issue.

sfriedman-stripe commented 4 months ago

@annie-gupta If you would like to create a pull request with a fix, we would be happy to take a look