Skip to content

Worker segfaults in Docker after ~12s on DO #27

@Shy

Description

@Shy

Hey Franz. I'm running into consistent segfaults when the worker runs in Docker/Linux environments (tested on DigitalOcean App Platform and locally) on a project.

Environment:

  • swift-temporal-sdk: 0.1.0
  • Swift: 6.2
  • Base image: swift:6.2-noble (single-stage) or ubuntu:24.04 (multi-stage runtime)
  • Platform: Linux ARM64 & x86_64

What's happening:

  • Worker connects to Temporal Cloud (mTLS) successfully
  • Server starts and reports ready
  • Worker crashes with SIGSEGV ~12 seconds after "Starting Temporal worker..."
  • Crash occurs in __swift_allocate_boxed_opaque_existential_1 during workflow execution

Crash logs (DigitalOcean):

[ INFO ] 👷 Starting Temporal worker... [attempt: 1]
swift-runtime: failed to suspend thread 1 while processing a crash; backtraces will be missing information
swift-runtime: failed to suspend thread 2 while processing a crash; backtraces will be missing information
[... many similar thread suspension failures ...]

*** Signal 11: Backtracing from 0x559a6d500e91... done ***

*** Program crashed: Bad pointer dereference at 0x0000100000010059 ***

Platform: x86_64 Linux (Ubuntu 24.04.3 LTS)

Thread 0 "tokio-runtime-w" crashed:

  0 [system]                0x0000559a6d500e91 __swift_allocate_boxed_opaque_existential_1 + 17
  1 [ra] [thunk]            0x0000559a6e3af801 thunk for @callee_guaranteed @async (@in_guaranteed Span) -> (@out A, @error @owned Error) + 128
  2 [ra]                    0x00007ea7f960ff50 swift::runJobInEstablishedExecutorContext(swift::Job*) + 367
  3 [ra]                    0x00007ea7f9610d47 swift_job_run_on_serial_and_task_executor + 86
  4 [ra] [inlined] [system] 0x0000559a6e45bd7f WorkflowTaskExecutor.run()
  5 [ra] [inlined]          0x0000559a6e45bd7f UnownedJob.runSynchronously(isolatedTo:taskExecutor:)
  6 [ra]                    0x0000559a6e45bd7f WorkflowInstance.runExecutor(context:) + 718 in WorkflowTaskExecutor.swift:74:21
  7 [ra]                    0x0000559a6e452af2 closure #2 in WorkflowInstance.run<A, B>(workflowType:activations:) + 81 in WorkflowInstance.swift:157:18
  8 [async]                 0x0000559a6e450be0 WorkflowInstance.run<A, B>(workflowType:activations:) in WorkflowInstance.swift:87

Attempted fixes:

  1. Swift runtime flags (didn't fix DO crash):
ENV SWIFT_DETERMINISTIC_HASHING=1
ENV SWIFT_BACKTRACE=enable=no
ENV LIBDISPATCH_COOPERATIVE_POOL_STRICT=0

Helped locally but still crashes on DigitalOcean.

  1. Multi-stage Docker build (different issue):
    Reduced image from 12.7GB → 2GB but introduces SSL certificate loading failures:
transportError: "Couldn't create SSL context" (cause: "failedToLoadCertificate")

Additional context:

  • Single-stage Docker image is 12.7GB (includes full Swift toolchain)
  • Running on 1GB RAM instance (DigitalOcean apps-s-1vcpu-1gb)
  • Native macOS builds work fine
  • Workflows are simple (single activity execution)

Curious if you have any work arounds for this one?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions