Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions osutil/syncdir.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
"io"
"os"
"path/filepath"
"runtime"
"runtime/debug"
"sort"
)

Expand Down Expand Up @@ -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)
Expand Down
41 changes: 41 additions & 0 deletions tests/main/inconsistent-common-id-reproducer/task.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading