Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is this a force unwrap ? My app just crashed #1730

Open
adirburke opened this issue Nov 9, 2024 · 10 comments
Open

Why is this a force unwrap ? My app just crashed #1730

adirburke opened this issue Nov 9, 2024 · 10 comments

Comments

@adirburke
Copy link

return String(bytes: data, encoding: .utf8)!

I just had a
Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value

The function is throwing couldn't you throw a nil error instead of force-unwrap

@adirburke
Copy link
Author

Complete Stack Trace

zaraapp-1 | swift-runtime: failed to suspend thread 60890 while processing a crash; backtraces will be missing information
zaraapp-1 | swift-runtime: failed to suspend thread 60890 while processing a crash; backtraces will be missing information
zaraapp-1 |
zaraapp-1 | *** Signal 4: Backtracing from 0x5c76c4306a32... done ***
zaraapp-1 |
zaraapp-1 | *** Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value ***
zaraapp-1 |
zaraapp-1 | Thread 32 "NIO-ELT-0-#7" crashed:
zaraapp-1 |
zaraapp-1 | 0 [inlined] [system] 0x00005c76c4306a32 Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value in issueServer at //
zaraapp-1 | 1 0x00005c76c4306a32 Message.jsonString(options:) + 386 in issueServer at /ZaraFull/.build/checkouts/swift-protobuf/Sources/SwiftProtobuf/Message+JSONAdditions.swift:35:52
zaraapp-1 | 2 [ra] 0x00005c76c4c13398 VaporHTTPAdapter.sendJson(:) + 535 in issueServer at /ZaraFull/Sources/zaraDatabaseWrapper/Sources/ZaraService/Controllers/VaporProtcols/VaporHTTPAdapter+HTTPResponse.swift:72:54
zaraapp-1 | 3 [ra] [thunk] 0x00005c76c4c14410 protocol witness for HTTPResponse.sendJson
(:) in conformance VaporHTTPAdapter + 15 in issueServer at //
zaraapp-1 | 4 [ra] 0x00005c76c4b79a90 RetrieveSimpleReservationsAction.handler(request:response:) + 399 in issueServer at /ZaraFull/Sources/zaraDatabaseWrapper/Sources/ZaraService/Controllers/ReservationController/Actions/RetrieveSimpleReservations.swift:102:26
zaraapp-1 | 5 [async] [thunk] 0x00005c76c4b7a580 protocol witness for ActionProtocol.handler(request:response:) in conformance RetrieveSimpleReservationsAction in issueServer at //
zaraapp-1 | 6 [async] 0x00005c76c4b82570 closure #2 in RoutesHandler.registerHandlers(for:to:) in issueServer at /ZaraFull/Sources/zaraDatabaseWrapper/Sources/ZaraService/RoutesHandler.swift:36
zaraapp-1 | 7 [async] [thunk] 0x00005c76c4b83510 partial apply for closure #2 in RoutesHandler.registerHandlers(for:to:) in issueServer at //
zaraapp-1 | 8 [async] 0x00005c76c4515000 closure #1 in RoutesBuilder.on(::body:use:) in issueServer at /ZaraFull/.build/checkouts/vapor/Sources/Vapor/Concurrency/RoutesBuilder+Concurrency.swift:148
zaraapp-1 | 9 [async] [thunk] 0x00005c76c45152e0 partial apply for closure #1 in RoutesBuilder.on(::body:use:) in issueServer at //
zaraapp-1 | 10 [async] [system] 0x00005c76c4500b00 specialized closure #1 in AsyncResponder.respond(to:) in issueServer at //
zaraapp-1 | 11 [async] [thunk] 0x00005c76c4500e90 partial apply for specialized closure #1 in AsyncResponder.respond(to:) in issueServer at //
zaraapp-1 | 12 [async] [system] 0x00005c76c4500000 specialized closure #1 in EventLoopPromise.completeWithTask(:) in issueServer at //
zaraapp-1 | 13 [async] [thunk] 0x00005c76c45017d0 partial apply for specialized closure #1 in EventLoopPromise.completeWithTask(
:) in issueServer
zaraapp-1 | 14 [async] [system] 0x00005c76c3b83f60 specialized thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A) in issueServer at //
zaraapp-1 | 15 [async] 0x00005c76c4501750 thunk for @escaping @isolated(any) @callee_guaranteed @async () -> (@out A)specialized partial apply in issueServer
zaraapp-1 | 16 [async] 0x00005c76c52c7010 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) in issueServer
zaraapp-1 |
zaraapp-1 |
zaraapp-1 | Registers:
zaraapp-1 |
zaraapp-1 | rax 0x0000000000000001 1
zaraapp-1 | rdx 0x0000000000000000 0
zaraapp-1 | rcx 0x0000000000000001 1
zaraapp-1 | rbx 0xffffffffffffe700 18446744073709545216
zaraapp-1 | rsi 0x0000728432286040 08 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 ················
zaraapp-1 | rdi 0x00007283fbcfcf98 40 ff c5 20 84 72 00 00 35 00 00 00 41 00 00 00 @ÿÅ ·r··5···A···
zaraapp-1 | rbp 0x00007283fbcfbed0 20 c0 cf fb 83 72 00 00 98 33 c1 c4 76 5c 00 00 ÀÏû·r···3ÁÄv\··
zaraapp-1 | rsp 0x00007283fbcfbe30 00 64 06 1b 84 72 00 00 00 00 00 00 00 00 00 00 ·d···r··········
zaraapp-1 | r8 0x00007284308008c0 c8 00 00 00 c8 00 00 00 c8 00 00 00 c8 00 00 00 È···È···È···È···
zaraapp-1 | r9 0x0000000000000a00 2560
zaraapp-1 | r10 0x0000000000000018 24
zaraapp-1 | r11 0x00007283fbcfe640 40 e6 cf fb 83 72 00 00 10 3e 60 15 84 72 00 00 @æÏû·r···>`··r··
zaraapp-1 | r12 0x0000000000000000 0
zaraapp-1 | r13 0x000072841e862400 d8 45 7e c6 76 5c 00 00 03 00 00 00 01 00 00 00 ØE~Æv\··········
zaraapp-1 | r14 0x0000000000000000 0
zaraapp-1 | r15 0x0000000000000000 0
zaraapp-1 | rip 0x00005c76c4306a32 0f 0b 66 66 66 2e 0f 1f 84 00 00 00 00 00 55 48 ··fff.········UH
zaraapp-1 |
zaraapp-1 | rflags 0x0000000000010246 ZF PF
zaraapp-1 |
zaraapp-1 | cs 0x0033 fs 0x0000 gs 0x0000
zaraapp-1 |
zaraapp-1 |
zaraapp-1 | Images:
zaraapp-1 |
zaraapp-1 | 0x00005c76c26d8000–0x00005c76c669fce0 issueServer /run/issueServer
zaraapp-1 | 0x0000728430b85000–0x0000728430b8d749 cd2d2f71b3967ebde30e2aa43b8eb63339020c06 libmd.so.0.0.5 /usr/lib/x86_64-linux-gnu/libmd.so.0.0.5
zaraapp-1 | 0x0000728430b94000–0x0000728430ba4235 9a6c72469251e2feb63e175ef5cb944ce6e00df3 libbsd.so.0.11.5 /usr/lib/x86_64-linux-gnu/libbsd.so.0.11.5
zaraapp-1 | 0x0000728430bac000–0x0000728430bb43a1 59c2a6b204f74f358ca7711d2dfd349d88711f6a libffi.so.8.1.0 /usr/lib/x86_64-linux-gnu/libffi.so.8.1.0
zaraapp-1 | 0x0000728430bb9000–0x0000728430bbc975 6b60f99504aa1d3999ea02a14366d1a39d6c5dcf libXdmcp.so.6.0.0 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
zaraapp-1 | 0x0000728430bc1000–0x0000728430bc30a1 7089b383cacbfc1760634a3be19a923e51fe3315 libXau.so.6.0.0 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
zaraapp-1 | 0x0000728430bc7000–0x0000728430bd3239 95ebf3f0e57d22d884105b9316288167790a36fb libresolv.so.2 /usr/lib/x86_64-linux-gnu/libresolv.so.2
zaraapp-1 | 0x0000728430bdd000–0x0000728430be0411 ff27227afa5eeddccab180dd29bd7fcff94aea7c libkeyutils.so.1.9 /usr/lib/x86_64-linux-gnu/libkeyutils.so.1.9
zaraapp-1 | 0x0000728430be4000–0x0000728430bf4219 2fde6ecb43c586fe4077118f771077aa1298e7ea libtasn1.so.6.6.2 /usr/lib/x86_64-linux-gnu/libtasn1.so.6.6.2
zaraapp-1 | 0x0000728430bfc000–0x0000728430cc83ad a0ffe1d002de5812dc718186172efb78604ddf2c libp11-kit.so.0.3.0 /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.3.0
zaraapp-1 | 0x0000728430d37000–0x0000728430d5566d 1bef862a339557aa16c34c7a4b27f8f3aea90517 libxcb.so.1.1.0 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
zaraapp-1 | 0x0000728430d61000–0x0000728430d625c5 43a72967cf84155914c8b3e915926733d1e57c11 libbrotlicommon.so.1.0.9 /usr/lib/x86_64-linux-gnu/libbrotlicommon.so.1.0.9
zaraapp-1 | 0x0000728430d86000–0x0000728430d990f1 b8a924f277180f8743a0c6463a379b1a4ad1aae5 libsasl2.so.2.0.25 /usr/lib/x86_64-linux-gnu/libsasl2.so.2.0.25
zaraapp-1 | 0x0000728430da1000–0x0000728430da9a31 f58f4ed7c296c30c240753420a451da43518cc04 libkrb5support.so.0.1 /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
zaraapp-1 | 0x0000728430daf000–0x0000728430db1f69 034d7bc7ded23dc6d02c05aad4c0f7b203881721 libcom_err.so.2.1 /usr/lib/x86_64-linux-gnu/libcom_err.so.2.1
zaraapp-1 | 0x0000728430db5000–0x0000728430dd3601 93691953307d918936c1eda0c5f5cf73f72af0b0 libk5crypto.so.3.1 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
zaraapp-1 | 0x0000728430de4000–0x0000728430e61b85 1e24e996e3708e3bb3cb2cac71451fc185ba35e9 libkrb5.so.3.3 /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
zaraapp-1 | 0x0000728430eb1000–0x0000728430f1955d f110719303ddbea25a5e89ff730fec520eed67b0 libgmp.so.10.4.1 /usr/lib/x86_64-linux-gnu/libgmp.so.10.4.1
zaraapp-1 | 0x0000728430f33000–0x0000728430f5f7e9 3d9c6bf106ef53d625b7b1c8bb1300e84598a74a libnettle.so.8.4 /usr/lib/x86_64-linux-gnu/libnettle.so.8.4
zaraapp-1 | 0x0000728430f79000–0x0000728430f93b99 3cc4a3474de72db89e9dcc93bfb95fe377f48c37 libhogweed.so.6.4 /usr/lib/x86_64-linux-gnu/libhogweed.so.6.4
zaraapp-1 | 0x0000728430fc1000–0x000072843111aa8d 97b8f99f392f1fd37b969a7164bcea884e23649b libgnutls.so.30.31.0 /usr/lib/x86_64-linux-gnu/libgnutls.so.30.31.0
zaraapp-1 | 0x00007284311ac000–0x00007284311f2b66 ca5149da8d5a298b8f286ffca3d6e2402ec0fe01 libunistring.so.2.2.0 /usr/lib/x86_64-linux-gnu/libunistring.so.2.2.0
zaraapp-1 | 0x0000728431356000–0x0000728431372df5 702adff4f2f7536b32bba66ecaab25f470674927 libdeflate.so.0 /usr/lib/x86_64-linux-gnu/libdeflate.so.0
zaraapp-1 | 0x000072843137c000–0x0000728431386989 5ae70eb022297d6be039f37f3005fa9be544d394 libjbig.so.0 /usr/lib/x86_64-linux-gnu/libjbig.so.0
zaraapp-1 | 0x000072843138d000–0x00007284313aa0ed b85da6c48eb60a646615392559483b93617ef265 liblzma.so.5.2.5 /usr/lib/x86_64-linux-gnu/liblzma.so.5.2.5
zaraapp-1 | 0x00007284313b8000–0x000072843145c6dd 37a5d7bbb78e3a99ea8376a7c80ea0c62fe06494 libX11.so.6.4.0 /usr/lib/x86_64-linux-gnu/libX11.so.6.4.0
zaraapp-1 | 0x00007284314f8000–0x00007284314fdccd 2ad45e51f4ac4fc8b5f4ef938a18ca8e0a05e4af libuuid.so.1.3.0 /usr/lib/x86_64-linux-gnu/libuuid.so.1.3.0
zaraapp-1 | 0x0000728431501000–0x0000728431523685 e16bd88eff9c79f864766208d4e3de9e8dac1e2f libexpat.so.1.8.7 /usr/lib/x86_64-linux-gnu/libexpat.so.1.8.7
zaraapp-1 | 0x0000728431534000–0x000072843153c0e9 4b1f390dd6e24d49684db8b2443d082379e8e977 libbrotlidec.so.1.0.9 /usr/lib/x86_64-linux-gnu/libbrotlidec.so.1.0.9
zaraapp-1 | 0x0000728431542000–0x00007284315fdf11 5d9d0d946a3154a748e87e17af9d14764519237b libzstd.so.1.4.8 /usr/lib/x86_64-linux-gnu/libzstd.so.1.4.8
zaraapp-1 | 0x0000728431611000–0x000072843161b361 eb842ddeae4869aed7679cb518a427a13c397fa9 liblber-2.5.so.0.1.13 /usr/lib/x86_64-linux-gnu/liblber-2.5.so.0.1.13
zaraapp-1 | 0x0000728431622000–0x0000728431669e09 60e3f466b3064e2ca56d514bc770759d8ef1c1d6 libldap-2.5.so.0.1.13 /usr/lib/x86_64-linux-gnu/libldap-2.5.so.0.1.13
zaraapp-1 | 0x0000728431681000–0x00007284316c3b15 e137e268414a0f51fd39bf59189043de85df5227 libgssapi_krb5.so.2.2 /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
zaraapp-1 | 0x00007284316d5000–0x00007284319e5e31 55c2d087f6f4d9d01ae137a278cb4b440f75c237 libcrypto.so.3 /usr/lib/x86_64-linux-gnu/libcrypto.so.3
zaraapp-1 | 0x0000728431b1b000–0x0000728431b93f8d 6cf6c0a28868e07598c93a2824668d9fabe3260e libssl.so.3 /usr/lib/x86_64-linux-gnu/libssl.so.3
zaraapp-1 | 0x0000728431bbf000–0x0000728431bc2eb1 2b1afc1a3bc8bdb016e432c50db058632e7895b9 libpsl.so.5.3.2 /usr/lib/x86_64-linux-gnu/libpsl.so.5.3.2
zaraapp-1 | 0x0000728431bd3000–0x0000728431c22f25 b7fd78c4b3609dd386755b09bba2fb6b096d906b libssh.so.4.8.7 /usr/lib/x86_64-linux-gnu/libssh.so.4.8.7
zaraapp-1 | 0x0000728431c40000–0x0000728431c54fe9 9517ef375cd71ea3da824b4118f1599735093d66 librtmp.so.1 /usr/lib/x86_64-linux-gnu/librtmp.so.1
zaraapp-1 | 0x0000728431c5f000–0x0000728431c64589 45b73e0e1c46a76be22f572ee98c60af5768bf8f libidn2.so.0.3.7 /usr/lib/x86_64-linux-gnu/libidn2.so.0.3.7
zaraapp-1 | 0x0000728431c80000–0x0000728431c99805 b02e3f0f2201e893e2dc948840c6e380484c9623 libnghttp2.so.14.20.1 /usr/lib/x86_64-linux-gnu/libnghttp2.so.14.20.1
zaraapp-1 | 0x0000728431cac000–0x0000728431d0300d 939537c005a6d7ce229b175888a38f74fdd9dd4b libwebp.so.7.1.3 /usr/lib/x86_64-linux-gnu/libwebp.so.7.1.3
zaraapp-1 | 0x0000728431d19000–0x0000728431d69fd5 d599928676b625728e65b6f7bea3b5c83b31cdcd libtiff.so.5.7.0 /usr/lib/x86_64-linux-gnu/libtiff.so.5.7.0
zaraapp-1 | 0x0000728431da1000–0x0000728431db04b1 3b98a06f133efda298bbba1be3efa8d7f7129aa2 libXpm.so.4.11.0 /usr/lib/x86_64-linux-gnu/libXpm.so.4.11.0
zaraapp-1 | 0x0000728431db6000–0x0000728431e02876 c54abff9294357e28532a76a049a4cb2542fc15b libjpeg.so.8.2.2 /usr/lib/x86_64-linux-gnu/libjpeg.so.8.2.2
zaraapp-1 | 0x0000728431e37000–0x0000728431ecc5a9 bc6c65a19e6f75fea5e74a7fd6c0b91182e1a8b0 libfreetype.so.6.18.1 /usr/lib/x86_64-linux-gnu/libfreetype.so.6.18.1
zaraapp-1 | 0x0000728431eff000–0x0000728431f2eb2d 0bb435fdd5ec37178e14ea03bb36f779a4b72a94 libfontconfig.so.1.12.0 /usr/lib/x86_64-linux-gnu/libfontconfig.so.1.12.0
zaraapp-1 | 0x0000728431f4b000–0x0000728431f78489 d58bf7c11ac793d528926238d831792b5ef792cf libpng16.so.16.37.0 /usr/lib/x86_64-linux-gnu/libpng16.so.16.37.0
zaraapp-1 | 0x0000728431f86000–0x0000728432142341 490fef8403240c91833978d494d39e537409b92e libc.so.6 /usr/lib/x86_64-linux-gnu/libc.so.6
zaraapp-1 | 0x00007284321af000–0x00007284321c8815 e3a44e0da9c6e835d293ed8fd2882b4c4a87130c libgcc_s.so.1 /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
zaraapp-1 | 0x00007284321cf000–0x000072843227163d ffdb577fa78a283f51714728e64d35d30bac41a9 libjemalloc.so.2 /usr/lib/x86_64-linux-gnu/libjemalloc.so.2
zaraapp-1 | 0x00007284324a9000–0x00007284324bbc21 30840b79ac329ecbf1dec0bb60180eed256d319f libz.so.1.2.11 /usr/lib/x86_64-linux-gnu/libz.so.1.2.11
zaraapp-1 | 0x00007284324c5000–0x000072843266ffd1 e37fe1a879783838de78cbc8c80621fa685d58a2 libstdc++.so.6.0.30 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.30
zaraapp-1 | 0x00007284326f3000–0x000072843277c8d5 a508ec5d8bf12fb7fd08204e0f87518e5cd0b102 libm.so.6 /usr/lib/x86_64-linux-gnu/libm.so.6
zaraapp-1 | 0x00007284327da000–0x000072843285d1f1 742a0bd041fc466b53c12647ec52957852ba351b libcurl.so.4.7.0 /usr/lib/x86_64-linux-gnu/libcurl.so.4.7.0
zaraapp-1 | 0x0000728432881000–0x00007284328b46b6 daf2f0ffdcc758a58425c07817bca08fdcea3fa6 libgd.so.3.0.8 /usr/lib/x86_64-linux-gnu/libgd.so.3.0.8
zaraapp-1 | 0x00007284328e9000–0x000072843290de1d 38f83c545237c8edf5e4993b1e85e22b8d08be65 libexif.so.12.3.4 /usr/lib/x86_64-linux-gnu/libexif.so.12.3.4
zaraapp-1 | 0x0000728432937000–0x000072843293e2bd 4f9fa80bf0b1ab4126ff01c1df0ebeb802ef09d2 libiptcdata.so.0.3.3 /usr/lib/x86_64-linux-gnu/libiptcdata.so.0.3.3
zaraapp-1 | 0x000072843294b000–0x0000728432976315 4186944c50f8a32b47d74931e3f512b811813b64 ld-linux-x86-64.so.2 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
zaraapp-1 |
zaraapp-1 | Backtrace took 144.25s
zaraapp-1 |
zaraapp-1 | Illegal instruction (core dumped)

@thomasvl
Copy link
Collaborator

thomasvl commented Nov 9, 2024

return String(bytes: data, encoding: .utf8)!

I just had a

Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value

The function is throwing couldn't you throw a nil error instead of force-unwrap

An error on that line implies the runtime generated invalid utf8. Do you have a repo of how you got the runtime to do that?

@Lukasa
Copy link
Contributor

Lukasa commented Nov 9, 2024

(As a sidebar, we can remove the force unwrap by replacing this with String(decoding:as:), which cannot return nil. But I agree with @thomasvl that I’m amazed we returned invalid UTF-8 here, and we should understand how that happened.)

@adirburke
Copy link
Author

I am unable to get it to crash again running the same command, How do you want the code represented? I cant share the whole repo as its confidential but I cant send snippets?

    public func sendJson<T>(_ value: T) throws where T : SwiftProtobuf.Message {
        self.request.logger.info("Sending JSON: \(value)")
        self.request.logger.info("Sending JSON: \(value.textFormatString())")
        if self.acceptBinary() {
            response?.headers.contentType = .init(type: "application", subType: "protobuf")
            response?.body = .init(data: try value.serializedData())
           
        } else {
            response?.headers.contentType = .json
            response?.body = .init(string: try value.jsonString())
        }
        self.completed()
    }

@thomasvl
Copy link
Collaborator

@adirburke I doubt the problem is your code per say, it's is going to be a specific field (or set of fields) being set to specific values that causes the problem. So to catch this you'd likely have to add some extra code to catch this and then start to inspect how the message is configure to figure out the exact problem.

thomasvl added a commit to thomasvl/swift-protobuf that referenced this issue Nov 11, 2024
Avoids the force unwraps that were needed before.

From the comment in apple#1730 (comment).
thomasvl added a commit to thomasvl/swift-protobuf that referenced this issue Nov 11, 2024
Avoids the force unwraps that were needed before.

From the comment in apple#1730 (comment).
@tbkka
Copy link
Collaborator

tbkka commented Nov 11, 2024

@adirburke -- Can you print out value.textFormatString() just before that happens and share that with us? That may give a clue as to what happened here.

There's some content in your message that we're failing to correctly convert to JSON and I'd like to track down exactly what that is. There are a few cases where we genuinely cannot produce correct JSON, but all such cases should already be throwing errors instead of producing invalid text. I fear that fixing this force-unwrap will hide that other bug.

@thomasvl
Copy link
Collaborator

@adirburke -- Can you print out value.textFormatString() just before that happens and share that with us? That may give a clue as to what happened here.

@tbkka - Sadly, that's probably going to fail also, as it traces back to

String(bytes: data, encoding: String.Encoding.utf8)!
, i.e. - the exact same call.

@adirburke
Copy link
Author

I'll send through the proto file and the generated code when I'm next at my laptop

Would that help ?

Not sure where to go from here . I had the same thought of doing a print before the convert to see but you pointed out it has a force unwrap too

Let me know how I can help find the bug

@Lukasa
Copy link
Contributor

Lukasa commented Nov 12, 2024

Given that an error handling path exists for us, a useful step might be to amend this code to throw an error in the nil return case. At least that avoids the crash. We could elect to crash in debug mode if we wanted to prompt issues to be filed for diagnostic purposes.

@thomasvl
Copy link
Collaborator

I'll send through the proto file and the generated code when I'm next at my laptop

Would that help ?

That might tells us what subset of field types are at play, but the real question is what data got into one of those fields that we failed to serialize to json correctly. Somehow catching those specifics is likely the important details.

Actually, relooking at you code snippet (#1730 (comment)), I'm realizing something strange. The snippet says there was a call to value.textFormatString() and that didn't fail, but
you said the call to value.jsonString() failed.

So I think that implies only two possible things:

  1. We have a bug specifically in the framing on the JSON vs. the TextFormat, and they share a lot of similar logic, so that's would be a little surprising (especially with all the Fuzz testing that has happened by now).
  2. There was some sort of memory corruption that happened here. I notice you stack trace said it was Thread 32. Do you have anything else linked into this binary that say isn't Swift and/or Swift that does a lot of Unsafe direct buffer management? Could this be a case of memory corruption from other code, and SwiftProtobuf just happens to be the thing that ran into the corrupted memory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants