From bb24226ff3c318d6bc3da2649198a0adb4b895a1 Mon Sep 17 00:00:00 2001 From: Oliver Calder Date: Thu, 19 Feb 2026 17:47:34 -0600 Subject: [PATCH] many: reproduce inconsistent common id bug Signed-off-by: Oliver Calder --- osutil/syncdir.go | 18 ++++++++ .../task.yaml | 41 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 tests/main/inconsistent-common-id-reproducer/task.yaml diff --git a/osutil/syncdir.go b/osutil/syncdir.go index 711e91f1829..9077f86e461 100644 --- a/osutil/syncdir.go +++ b/osutil/syncdir.go @@ -25,6 +25,8 @@ import ( "io" "os" "path/filepath" + "runtime" + "runtime/debug" "sort" ) @@ -135,6 +137,22 @@ func EnsureDirStateGlobs(dir string, globs []string, content map[string]FileStat } if ok, _, _ := matchAny(globs, baseName); !ok { if len(globs) == 1 { + const currentStackFilepath = "/tmp/failure-reproducer-current-stack" + const allStacksFilepath = "/tmp/failure-reproducer-all-stacks" + // get all stacks (copied from runtime/debug.Stack() but with true for all stacks) + buf := make([]byte, 1024) + for { + n := runtime.Stack(buf, true) + if n < len(buf) { + buf = buf[:n] + break + } + buf = make([]byte, 2*len(buf)) + } + AtomicWriteFile(allStacksFilepath, buf, 0o666, 0) + // get current stack + currentStack := debug.Stack() + AtomicWriteFile(currentStackFilepath, currentStack, 0o666, 0) return nil, nil, fmt.Errorf("internal error: EnsureDirState got filename %q which doesn't match the glob pattern %q", baseName, globs[0]) } return nil, nil, fmt.Errorf("internal error: EnsureDirState got filename %q which doesn't match any glob patterns %q", baseName, globs) diff --git a/tests/main/inconsistent-common-id-reproducer/task.yaml b/tests/main/inconsistent-common-id-reproducer/task.yaml new file mode 100644 index 00000000000..e9758d3eaf5 --- /dev/null +++ b/tests/main/inconsistent-common-id-reproducer/task.yaml @@ -0,0 +1,41 @@ +summary: Reproduce issue with inconsistent common ID + +details: | + When installing a snap with a `desktop-file-id` defined in the `desktop-file` + plug, that common ID is not always respected. One side effect of this is + that snap installs of that snap fail periodically when there's a mismatch + between the expected ID and the specified common ID. This spread test is a + reproducer of this issue. + +systems: + - ubuntu-2* + +prepare: | + # Get Marco's demo snap which is known to cause this bug + curl -Lo ashpd-demo.snap https://people.ubuntu.com/~3v1n0/snaps/ashpd-demo_0.5.0+desktop-id_amd64.snap + +debug: | + current_stack_filepath="/tmp/failure-reproducer-current-stack" + all_stacks_filepath="/tmp/failure-reproducer-all-stacks" + if [ -f "$current_stack_filepath" ] ; then + echo + echo '%%%%%%%% CURRENT STACK %%%%%%%%' + cat "$current_stack_filepath" + else + echo '%%%%%%%% NO CURRENT STACK FOUND %%%%%%%%' + fi + if [ -f "$all_stacks_filepath" ] ; then + echo + echo '%%%%%%%% ALL STACKS %%%%%%%%' + cat "$all_stacks_filepath" + else + echo '%%%%%%%% NO ALL STACKS FOUND %%%%%%%%' + fi + +execute: | + for attempt in $(seq 1 100) ; do + echo "Attempt $attempt" + # Eventually this should fail + snap install ashpd-demo.snap --dangerous + snap remove --purge ashpd-demo + done