Uploaded image for project: 'Swift'
  1. Swift
  2. SR-8980

Swift 4.2 runtime Segmentation Fault with release configuration

    XMLWordPrintable

    Details

      Description

      We have encountered an issue where Vapor 2.4.5 runs fine on the Swift 4.2 Ubuntu docker image in debug, but as soon as we change to building with the release configuration we get a Segmentation fault 19 out of 20 times we try to run the resulting executable. This doesn't happen when building with Xcode on macOS.

      I have raised a bug on the Vapor Github repo (https://github.com/vapor/vapor/issues/1829) informing them of this issue, but since it's a Swift runtime issue I thought it would be best to also raise a bug here so measures can be put in place to prevent it in future.

      Reproduction Steps

      1. Extract the example project (see attached) and navigate into the directory using terminal.
      2. Run
        docker run --rm -it --volume "$(pwd):/app" --workdir /app swift:4.2 /bin/bash
      1. Run
        swift build -c release
      1. Run the resulting executable
      2. Experience a Segmentation fault. (if it doesn't happen right away, stop the executable and run it again)

      From a core dump it looks like there is some issue with the dynamic casting:

      #0  0x00007f5c3d2a3124 in swift_dynamicCastMetatypeImpl(swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*) () from /usr/lib/swift/linux/libswiftCore.so
      (gdb) bt
      #0  0x00007f5c3d2a3124 in swift_dynamicCastMetatypeImpl(swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*) () from /usr/lib/swift/linux/libswiftCore.so
      #1  0x00007f5c3d052c0a in swift_swiftValueConformsTo () from /usr/lib/swift/linux/libswiftCore.so
      #2  0x00007f5c3d2a3be5 in _dynamicCastToExistential(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::DynamicCastFlags) () from /usr/lib/swift/linux/libswiftCore.so
      #3  0x00007f5c3d2a33fd in checkDynamicCastFromOptional(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, swift::DynamicCastFlags)
          () from /usr/lib/swift/linux/libswiftCore.so
      #4  0x00007f5c3d2a1fcf in swift_dynamicCastImpl(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, swift::DynamicCastFlags) ()
         from /usr/lib/swift/linux/libswiftCore.so
      #5  0x0000559c49f0e480 in $S7Configs6ConfigC5VaporE13customResolve6unique4file7keyPath2as7defaultxSS_SSSaySSGxmxACKXEtKlFAD11LogProtocol_p_Tg5011$S7Configs6b9C5Vapor11lM39_ps5Error_pIggozo_AcdE_psAF_pIeggrzo_TRAcdL_ps0S0_pIggozo_Tf1nnnncn_nTf4xnndnn_nTm ()
      #6  0x0000559c49f0e03d in $S7Configs6ConfigC5VaporE13customResolve6unique4file7keyPath2as7defaultxSS_SSSaySSGxmxACKXEtKlF7Console0L8Protocol_p_Tg5011$S7Configs6b12C7Console0C8M39_ps5Error_pIggozo_AcdE_psAF_pIeggrzo_TRAclM_ps0T0_pIggozo_Tf1nnnncn_nTf4xnndnn_n ()
      #7  0x0000559c49f2a7eb in $S5Vapor7DropletC6config6router6server6client10middleware7console3log4hash6cipher8commands4view5cache4mailAC7Configs6ConfigCSg_7Routing6RouterCSgAA21ServerFactoryProtocol_pSgAA06ClientuV0_pSgSay4HTTP10Middleware_pGSg7Console0zV0_pSgAA03LogV0_pSgAA04HashV0_pSgAA06CipherV0_pSgSayA5_7Command_pGSgAA12ViewRenderer_pSg5Cache05CacheV0_pSgAA04MailV0_pSgtKcfcTf4ggnngggnnggnnn_n ()
      #8  0x0000559c49f28590 in $S5Vapor7DropletCyAC7Configs6ConfigCKcfC ()
      #9  0x0000559c49eba71d in main ()
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            dlbuckley Dale Buckley
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: