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

A emoji parameter bug On Linux #299

Open
hellomsg opened this issue Dec 7, 2020 · 1 comment
Open

A emoji parameter bug On Linux #299

hellomsg opened this issue Dec 7, 2020 · 1 comment

Comments

@hellomsg
Copy link

hellomsg commented Dec 7, 2020

Platform: Linux(not happen on Mac)
What happen: the server shutdown
How to happen: remove permeter escapeVS, request body is 'πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦'
Strange: set parameter escapeVS or request not contains 'πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦', this wouldn't happen.
My question: Is the postParams wrong when the request body contains some speical emoji?

this is my request:

curl --location --request POST 'http://localhost:8181/emoji/parse?a=b' \
--header 'Content-Type: text/plain' \
--data-raw 'πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦'

this is my code:

func emojiParse(request: HTTPRequest, response: HTTPResponse) {
    do {
        let escapeVS = request.param(name: "escapeVS", defaultValue: "false")?.elementsEqual("true") ?? false
        if let raw = request.postBodyString {
            response.setHeader(.contentType, value: MimeType.forExtension("json"))
            let result = raw.translateUEmojiCode(escapeVS)
            try response.setBody(json: result)
        }
    } catch {
        response.status = .internalServerError
        response.setBody(string: "Error handling request: \(error)")
    }
    response.completed()
}

this is my debug on Mac:

image

this is the error log:

content:Fatal error: UnsafeMutablePointer.initialize overlapping range: file /home/buildnode/jenkins/workspace/oss-swift-5.2-package-linux-ubuntu-18_04/swift/stdlib/public/core/UnsafePointer.swift, line 832
content:Current stack trace:
content:0    libswiftCore.so                    0x00007fe6d9fc6db0 swift_reportError + 50
content:1    libswiftCore.so                    0x00007fe6da038f60 _swift_stdlib_reportFatalErrorInFile + 115
content:2    libswiftCore.so                    0x00007fe6d9d4d5f5 <unavailable> + 1381877
content:3    libswiftCore.so                    0x00007fe6d9d4d117 <unavailable> + 1380631
content:4    libswiftCore.so                    0x00007fe6d9d4cde3 <unavailable> + 1379811
content:5    libswiftCore.so                    0x00007fe6d9d4c750 _assertionFailure(_:_:file:line:flags:) + 525
content:6    libswiftCore.so                    0x00007fe6d9d4ccb0 _fatalErrorMessage(_:_:file:line:flags:) + 44
content:7    libswiftCore.so                    0x00007fe6d9f6ae72 <unavailable> + 3599986
content:8    PerfectTemplate                    0x0000562ce0eea388 <unavailable> + 992136
content:9    PerfectTemplate                    0x0000562ce0e85404 <unavailable> + 578564
content:10   PerfectTemplate                    0x0000562ce0e82862 <unavailable> + 567394
content:11   PerfectTemplate                    0x0000562ce0e819e3 <unavailable> + 563683
content:12   PerfectTemplate                    0x0000562ce0e5564d <unavailable> + 382541
content:13   PerfectTemplate                    0x0000562ce0f03097 <unavailable> + 1093783
content:14   PerfectTemplate                    0x0000562ce0e6f7c5 <unavailable> + 489413
content:15   PerfectTemplate                    0x0000562ce0e6fda9 <unavailable> + 490921
content:16   PerfectTemplate                    0x0000562ce0e85eb4 <unavailable> + 581300
content:17   PerfectTemplate                    0x0000562ce0ec1159 <unavailable> + 823641
content:18   PerfectTemplate                    0x0000562ce0ebf1bc <unavailable> + 815548
content:19   PerfectTemplate                    0x0000562ce0ec1d77 <unavailable> + 826743
content:20   PerfectTemplate                    0x0000562ce0e812d7 <unavailable> + 561879
content:21   PerfectTemplate                    0x0000562ce0e80e79 <unavailable> + 560761
content:22   PerfectTemplate                    0x0000562ce0ef7df9 <unavailable> + 1048057
content:23   PerfectTemplate                    0x0000562ce0ebee50 <unavailable> + 814672
content:24   PerfectTemplate                    0x0000562ce0ec1bd7 <unavailable> + 826327
content:25   PerfectTemplate                    0x0000562ce0e85cc9 <unavailable> + 580809
content:26   libdispatch.so                     0x00007fe6d8df3487 <unavailable> + 140423
content:27   libdispatch.so                     0x00007fe6d8dfb14a <unavailable> + 172362
content:28   libdispatch.so                     0x00007fe6d8dfaec8 <unavailable> + 171720
content:29   libdispatch.so                     0x00007fe6d8e07993 <unavailable> + 223635
content:30   libpthread.so.0                    0x00007fe6d99e46db <unavailable> + 30427
content:31   libc.so.6                          0x00007fe6d588f850 clone + 63
content:Fatal error: UnsafeMutablePointer.initialize overlapping range: file /home/buildnode/jenkins/workspace/oss-swift-5.2-package-linux-ubuntu-18_04/swift/stdlib/public/core/UnsafePointer.swift, line 832
content:Current stack trace:
content:0    libswiftCore.so                    0x00007fdc837b5db0 swift_reportError + 50
content:1    libswiftCore.so                    0x00007fdc83827f60 _swift_stdlib_reportFatalErrorInFile + 115
content:2    libswiftCore.so                    0x00007fdc8353c5f5 <unavailable> + 1381877
content:3    libswiftCore.so                    0x00007fdc8353c117 <unavailable> + 1380631
content:4    libswiftCore.so                    0x00007fdc8353bde3 <unavailable> + 1379811
content:5    libswiftCore.so                    0x00007fdc8353b750 _assertionFailure(_:_:file:line:flags:) + 525
content:6    libswiftCore.so                    0x00007fdc8353bcb0 _fatalErrorMessage(_:_:file:line:flags:) + 44
content:7    libswiftCore.so                    0x00007fdc83759e72 <unavailable> + 3599986
content:8    PerfectTemplate                    0x000055ebe9e40388 <unavailable> + 992136
content:9    PerfectTemplate                    0x000055ebe9ddb404 <unavailable> + 578564
content:10   PerfectTemplate                    0x000055ebe9dd8862 <unavailable> + 567394
content:11   PerfectTemplate                    0x000055ebe9dd79e3 <unavailable> + 563683
content:12   PerfectTemplate                    0x000055ebe9dab64d <unavailable> + 382541
content:13   PerfectTemplate                    0x000055ebe9e59098 <unavailable> + 1093784
content:14   PerfectTemplate                    0x000055ebe9dc57c5 <unavailable> + 489413
content:15   PerfectTemplate                    0x000055ebe9dc5da9 <unavailable> + 490921
content:16   PerfectTemplate                    0x000055ebe9ddbeb4 <unavailable> + 581300
content:17   PerfectTemplate                    0x000055ebe9e17159 <unavailable> + 823641
content:18   PerfectTemplate                    0x000055ebe9e151bc <unavailable> + 815548
content:19   PerfectTemplate                    0x000055ebe9e17d77 <unavailable> + 826743
content:20   PerfectTemplate                    0x000055ebe9dd72d7 <unavailable> + 561879
content:21   PerfectTemplate                    0x000055ebe9dd6e79 <unavailable> + 560761
content:22   PerfectTemplate                    0x000055ebe9e4ddf9 <unavailable> + 1048057
content:23   PerfectTemplate                    0x000055ebe9e14e50 <unavailable> + 814672
content:24   PerfectTemplate                    0x000055ebe9e17bd7 <unavailable> + 826327
content:25   PerfectTemplate                    0x000055ebe9ddbcc9 <unavailable> + 580809
content:26   libdispatch.so                     0x00007fdc825e2487 <unavailable> + 140423
content:27   libdispatch.so                     0x00007fdc825ea14a <unavailable> + 172362
content:28   libdispatch.so                     0x00007fdc825e9ec8 <unavailable> + 171720
content:29   libdispatch.so                     0x00007fdc825f6993 <unavailable> + 223635
content:30   libpthread.so.0                    0x00007fdc831d36db <unavailable> + 30427
content:31   libc.so.6                          0x00007fdc7f07f6e0 clone + 63
content:Fatal error: UnsafeMutablePointer.initialize overlapping range: file /home/buildnode/jenkins/workspace/oss-swift-5.2-package-linux-ubuntu-18_04/swift/stdlib/public/core/UnsafePointer.swift, line 832
content:Current stack trace:
content:0    libswiftCore.so                    0x00007fbb8658edb0 swift_reportError + 50
content:1    libswiftCore.so                    0x00007fbb86600f60 _swift_stdlib_reportFatalErrorInFile + 115
content:2    libswiftCore.so                    0x00007fbb863155f5 <unavailable> + 1381877
content:3    libswiftCore.so                    0x00007fbb86315117 <unavailable> + 1380631
content:4    libswiftCore.so                    0x00007fbb86314de3 <unavailable> + 1379811
content:5    libswiftCore.so                    0x00007fbb86314750 _assertionFailure(_:_:file:line:flags:) + 525
content:6    libswiftCore.so                    0x00007fbb86314cb0 _fatalErrorMessage(_:_:file:line:flags:) + 44
content:7    libswiftCore.so                    0x00007fbb86532e72 <unavailable> + 3599986
content:8    PerfectTemplate                    0x00005568021bb388 <unavailable> + 992136
content:9    PerfectTemplate                    0x0000556802156404 <unavailable> + 578564
content:10   PerfectTemplate                    0x0000556802153862 <unavailable> + 567394
content:11   PerfectTemplate                    0x00005568021529e3 <unavailable> + 563683
content:12   PerfectTemplate                    0x000055680212664d <unavailable> + 382541
content:13   PerfectTemplate                    0x00005568021d4098 <unavailable> + 1093784
content:14   PerfectTemplate                    0x00005568021407c5 <unavailable> + 489413
content:15   PerfectTemplate                    0x0000556802140da9 <unavailable> + 490921
content:16   PerfectTemplate                    0x0000556802156eb4 <unavailable> + 581300
content:17   PerfectTemplate                    0x0000556802192159 <unavailable> + 823641
content:18   PerfectTemplate                    0x00005568021901bc <unavailable> + 815548
content:19   PerfectTemplate                    0x0000556802192d77 <unavailable> + 826743
content:20   PerfectTemplate                    0x00005568021522d7 <unavailable> + 561879
content:21   PerfectTemplate                    0x0000556802151e79 <unavailable> + 560761
content:22   PerfectTemplate                    0x00005568021c8df9 <unavailable> + 1048057
content:23   PerfectTemplate                    0x000055680218fe50 <unavailable> + 814672
content:24   PerfectTemplate                    0x0000556802192bd7 <unavailable> + 826327
content:25   PerfectTemplate                    0x0000556802156cc9 <unavailable> + 580809
content:26   libdispatch.so                     0x00007fbb853bb487 <unavailable> + 140423
content:27   libdispatch.so                     0x00007fbb853c314a <unavailable> + 172362
content:28   libdispatch.so                     0x00007fbb853c2ec8 <unavailable> + 171720
content:29   libdispatch.so                     0x00007fbb853cf993 <unavailable> + 223635
content:25   PerfectTemplate                    0x0000564fcaa38cc9 <unavailable> + 580809
content:26   libdispatch.so                     0x00007f201bcb2487 <unavailable> + 140423
content:27   libdispatch.so                     0x00007f201bcba14a <unavailable> + 172362
content:28   libdispatch.so                     0x00007f201bcb9ec8 <unavailable> + 171720
content:29   libdispatch.so                     0x00007f201bcc6993 <unavailable> + 223635
content:30   libpthread.so.0                    0x00007f201c8a36db <unavailable> + 30427
content:31   libc.so.6                          0x00007f201874f6e0 clone + 63

--------UPDATE----------

this request also trigger the bug.

curl --location --request POST 'localhost:8181/emoji/parse?escapeVS=false&πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦=b' \
--header 'Content-Type: text/plain' \
--data-raw '123xds'

--------UPDATE----------

Looks like a swift unicode bug on Linux?

@hellomsg hellomsg changed the title A bug On Linux A emoji parameter bug On Linux Dec 7, 2020
@hellomsg
Copy link
Author

hellomsg commented Dec 7, 2020

This problem will cause the server shutdown. @kjessup

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

1 participant