Skip to content

🐞 engine crash in telemetry stack #8830

Closed

Description

@jedevc

Originally reported by @helderco in #8812 (comment)

It's possible to crash the engine (v0.13.6) deep in the telemetry stack:

panic: runtime error: cannot convert slice with length 0 to array or pointer to array with length 16
β”‚
β”‚ github.com/dagger/dagger/engine/telemetry.ReexportLogsFromPB({0x287f500, 0xc0b038b3b0}, {0x2873b50, 0xc08ceef800}, 0xc0846a8a80)
β”‚     /app/engine/telemetry/logs.go:35 +0x9df
β”‚ github.com/dagger/dagger/engine/server.(*PubSub).LogsHandler.func1()
β”‚     /app/engine/server/telemetry.go:136 +0xa5
β”‚ golang.org/x/sync/errgroup.(*Group).Go.func1()
β”‚     /go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:78 +0x50
β”‚ created by golang.org/x/sync/errgroup.(*Group).Go in goroutine 4381201
β”‚     /go/pkg/mod/golang.org/x/[email protected]/errgroup/errgroup.go:75 +0x96                

You can reproduce the failure by checking out fe7f1c4 (#8812):

And then running:

$ dagger call sdk python test

The engine should crash with the above error.

Not 100% sure what's going on, but it looks like we end up with a log record that has no trace id?

for _, rec := range scopeLog.GetLogRecords() {
var logRec log.Record
tid := trace.TraceID(rec.GetTraceId())

Definitely seems like this is caused by #8812 in part, but also we should guard against this happening in the engine - SDKs shouldn't be able to crash the engine.

Activity

  1. added
    kind/bug
    on Oct 31, 2024
  2. changed the title [-]:lady_beetle: engine crash in telemetry stack[/-] [+]🐞 engine crash in telemetry stack[/+] on Oct 31, 2024
  3. helderco commented on Nov 16, 2024

    @helderco
    Contributor

    Definitely seems like this is caused by #8812 in part, but also we should guard against this happening in the engine - SDKs shouldn't be able to crash the engine.

    Turns out, that PR was just triggering an issue that exists in main still. It has to do with a test in pytest triggering a log after another test used a connection on its own event loop, and when in a nested session (even without ExperimentalPrivilegedNesting).

    I’ve fixed the PR to avoid the warning in the first place, but also in the Python SDK’s test suite, to ensure telemetry is initialized properly.

    I can reproduce this even with a Go module, and without pytest, to avoid some questionable variables. Note that dagger run doesn’t trigger this issue, nor a single function call. I’m also not entirely sure pytest creates a event loop per test but it makes sense that it does (depending on test scope), and it’s what I could reproduce, including the fix.

    Example reproducer:

    package main
    
    import (
    	"dagger/test/internal/dagger"
    )
    
    const Script = `
    import logging
    import anyio
    import dagger
    from dagger import telemetry
    
    logger = logging.getLogger(__name__)
    
    
    async def test_conn():
        print("Estabilishing connection...")
        async with dagger.connection():
            print("  Success...")
        print("  Done")
    
    
    def test_log():
        print("Sending log...")
        logger.warning("This is a warning")
        print("  Warning sent")
    
    `
    
    const Success = `
    test_log()
    anyio.run(test_conn)
    `
    
    const Failure = `
    anyio.run(test_conn)
    test_log()
    `
    
    const Fixed = `
    telemetry.initialize()
    anyio.run(test_conn)
    test_log()
    `
    
    type Test struct{}
    
    func (m Test) Pass() *dagger.Container {
    	return m.run(Success)
    }
    
    func (m Test) Fail() *dagger.Container {
    	return m.run(Failure)
    }
    
    func (m Test) Fix() *dagger.Container {
    	return m.run(Fixed)
    }
    
    func (Test) run(main string) *dagger.Container {
    	return dag.Container().
    		From("ghcr.io/astral-sh/uv:python3.12-bookworm-slim").
    		WithNewFile("/test.py", Script+main).
    		WithExec(
    			[]string{"uv", "run", "--with", "dagger-io", "/test.py"},
    			dagger.ContainerWithExecOpts{
    				ExperimentalPrivilegedNesting: true,
    			},
    		)
    }

    pass

    It’s not an issue if the log comes before the client connection:

    test_log()
    anyio.run(test_conn)

    Output:

    ❯ dagger call pass stdout
    Sending log...
      Warning sent
    Estabilishing connection...
      Success...
      Done

    It’s also not an issue if they’re in the same event loop:

    async def test_conn():
        async with dagger.connection():
            ...
        test_log()  # βœ…
    
    anyio.run(test_conn)

    fail

    Engine crashes if log is sent after an event loop has finished establishing a client connection:

    anyio.run(test_conn)
    test_log()  # ❌

    Error:

    ❯ dagger call fail stdout
    Error: response from query: Post "http://dagger/query": command [docker exec -i dagger-engine-v0.13.7 buildctl dial-stdio] has exited with exit status 137, make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=

    fix

    I can fix the issue by making sure telemetry is initialized beforehand:

    telemetry.initialize() # πŸ‘ˆ
    anyio.run(test_conn)
    test_log()

    Output:

    ❯ dagger call fix stdout
    Estabilishing connection...
      Success...
      Done
    Sending log...
      Warning sent
  4. gmile commented on Mar 2, 2025

    @gmile
    Contributor

    What seems like a similar issue appears to still exist as of 0.16.2. I'm hitting it like this:

    1. create an empty dir and initialize elixir SDK in it,
    2. run dagger function command several times

    Repeatedly running dagger function succeeds most of the times, but occasionally would fail with either of these two errors:

    ✘ load module 1.3s
    ! failed to get configured module: Post "http://dagger/query": unexpected EOF
    β”‚ ✘ finding module configuration 1.3s
    β”‚ ! Post "http://dagger/query": unexpected EOF
    β”‚ β”‚ βˆ… moduleSource(refString: "."): ModuleSource! 2.5s
    
    ✘ load module 1.9s
    ! failed to get configured module: Post "http://dagger/query": command [docker exec -i dagger-engine-v0.16.2 buildctl dial-stdio] has exited with exit status 137, make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=
    β”‚ ✘ finding module configuration 1.9s
    β”‚ ! Post "http://dagger/query": command [docker exec -i dagger-engine-v0.16.2 buildctl dial-stdio] has exited with exit status 137, make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=
    β”‚ β”‚ βˆ… moduleSource(refString: "."): ModuleSource! 3.1s
    Error: failed to get configured module: Post "http://dagger/query": command [docker exec -i dagger-engine-v0.16.2 buildctl dial-stdio] has exited with exit status 137, make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=
    
    Full log
    eugene@IEVGENs-MacBook-Pro ~/oss> mkdir for-slides-march-2025
    eugene@IEVGENs-MacBook-Pro ~/oss> cd for-slides-march-2025/
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger init --sdk=elixir .
    βœ” connect 31.9s
    
    βœ” moduleSource(allowNotExists: true, disableFindUp: true, refString: ".", requireKind: LOCAL_SOURCE): ModuleSource! 0.0s
    βœ” .configExists: Boolean! 0.0s
    
    βœ” ModuleSource.localContextDirectoryPath: String! 0.0s
    
    βœ” ModuleSource.sourceRootSubpath: String! 0.0s
    
    βœ” ModuleSource.withName(name: "for-slides-march-2025"): ModuleSource! 0.0s
    βœ” .withSDK(source: "elixir"): ModuleSource! 16.6s
    βœ” .withSourceSubpath(path: "."): ModuleSource! 0.1s
    βœ” .withEngineVersion(version: "latest"): ModuleSource! 0.0s
    βœ” .generatedContextDirectory: Directory! 15.2s
    βœ” .export(path: "/Users/eugene/oss/for-slides-march-2025"): String! 1.0s
    
    12:33:34 WRN no LICENSE file found; generating one for you, feel free to change or remove license=Apache-2.0
    Initialized module for-slides-march-2025 in /Users/eugene/oss/for-slides-march-2025
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.2s
    βœ” load module 10.0s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    ✘ load module 2.4s
    ! failed to get configured module: Post "http://dagger/query": command [docker exec -i dagger-engine-v0.16.2 buildctl dial-stdio] has exited with exit status 137, make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=
    β”‚ ✘ finding module configuration 2.4s
    β”‚ ! Post "http://dagger/query": command [docker exec -i dagger-engine-v0.16.2 buildctl dial-stdio] has exited with exit status 137, make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=
    β”‚ β”‚ βˆ… moduleSource(refString: "."): ModuleSource! 3.6s
    Error: failed to get configured module: Post "http://dagger/query": command [docker exec -i dagger-engine-v0.16.2 buildctl dial-stdio] has exited with exit status 137, make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025 [1]> dagger functions
    βœ” connect 0.1s
    βœ” load module 6.2s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    ✘ load module 2.1s
    ! failed to get configured module: Post "http://dagger/query": unexpected EOF
    β”‚ ✘ finding module configuration 2.1s
    β”‚ ! Post "http://dagger/query": unexpected EOF
    β”‚ β”‚ βˆ… moduleSource(refString: "."): ModuleSource! 3.3s
    Error: failed to get configured module: Post "http://dagger/query": unexpected EOF
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025 [1]> dagger functions
    βœ” connect 0.1s
    βœ” load module 5.6s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    βœ” load module 3.0s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    βœ” load module 3.2s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    βœ” load module 3.7s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.2s
    ✘ load module 2.3s
    ! failed to get configured module: Post "http://dagger/query": unexpected EOF
    β”‚ ✘ finding module configuration 2.3s
    β”‚ ! Post "http://dagger/query": unexpected EOF
    β”‚ β”‚ βˆ… moduleSource(refString: "."): ModuleSource! 3.6s
    Error: failed to get configured module: Post "http://dagger/query": unexpected EOF
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025 [1]> dagger functions
    βœ” connect 0.1s
    βœ” load module 6.3s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    βœ” load module 3.2s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    βœ” load module 3.0s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    βœ” load module 3.0s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    βœ” load module 2.8s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025>
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    βœ” load module 3.3s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    βœ” load module 2.9s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    βœ” load module 3.0s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    ✘ load module 1.9s
    ! failed to get configured module: Post "http://dagger/query": command [docker exec -i dagger-engine-v0.16.2 buildctl dial-stdio] has exited with exit status 137, make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=
    β”‚ ✘ finding module configuration 1.9s
    β”‚ ! Post "http://dagger/query": command [docker exec -i dagger-engine-v0.16.2 buildctl dial-stdio] has exited with exit status 137, make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=
    β”‚ β”‚ βˆ… moduleSource(refString: "."): ModuleSource! 3.1s
    Error: failed to get configured module: Post "http://dagger/query": command [docker exec -i dagger-engine-v0.16.2 buildctl dial-stdio] has exited with exit status 137, make sure the URL is valid, and Docker 18.09 or later is installed on the remote host: stderr=
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025 [1]> dagger functions
    βœ” connect 0.1s
    βœ” load module 4.6s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    βœ” load module 2.9s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.2s
    ✘ load module 1.3s
    ! failed to get configured module: Post "http://dagger/query": unexpected EOF
    β”‚ ✘ finding module configuration 1.3s
    β”‚ ! Post "http://dagger/query": unexpected EOF
    β”‚ β”‚ βˆ… moduleSource(refString: "."): ModuleSource! 2.5s
    Error: failed to get configured module: Post "http://dagger/query": unexpected EOF
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025 [1]> dagger functions
    βœ” connect 0.1s
    βœ” load module 4.6s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    βœ” load module 2.9s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    eugene@IEVGENs-MacBook-Pro ~/o/for-slides-march-2025> dagger functions
    βœ” connect 0.1s
    βœ” load module 3.4s
    
    Name             Description
    container-echo   Returns a container that echoes whatever string argument is provided.
    grep-dir         Returns lines that match a pattern in the files of the provided Directory.
    
  5. locked and limited conversation to collaborators on Mar 24, 2026
  6. converted this issue into a discussion #12219 on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions