Stash crashes when scanning, bringing down the entire container

When scanning my library, stash crashes with an index out of bounds error. It brings the entire stash container down, terminating stash. stash is unusable in this form.

logs :

INFO[2026-01-21 07:38:47] Calculating fingerprints for /data/Tigresavip.com.br Siterip/Flakael mete na minha buceta e depois gosa na minha boca.mp4 ... 
INFO[2026-01-21 07:38:48] /media/XXX/video/Tigresavip.com.br Siterip/Estava lavando louça chegou Veltin e Flakael, transei com os dois ali mesmo rolou até dupla penetração.mp4 moved to /data/Tigresavip.com.br Siterip/Estava lavando louça chegou Veltin e Flakael, transei com os dois ali mesmo rolou até dupla penetração.mp4. Updating path... 
INFO[2026-01-21 07:38:48] Calculating fingerprints for /data/Tigresavip.com.br Siterip/Fui no quarto dos meninos ai Veltin e Flakael quis me comer, metemos mais de hora e rolou aquela D.P deliciosas com as.mp4 ... 
panic: runtime error: index out of range [155] with length 155 [recovered]
        panic: runtime error: index out of range [155] with length 155

goroutine 9928 [running]:
github.com/stashapp/stash/pkg/txn.withTxn.func1()
        github.com/stashapp/stash/pkg/txn/transaction.go:65 +0x2f3
panic({0x14b44f22eaa0?, 0xc004cc98a8?})
        runtime/panic.go:792 +0x132
github.com/stashapp/stash/pkg/fsutil.IsFsPathCaseSensitive({0xc00c8280a0, 0x9b})
        github.com/stashapp/stash/pkg/fsutil/fs.go:37 +0x293
github.com/stashapp/stash/pkg/file.(*OsFS).IsPathCaseSensitive(0xc0002b5d40?, {0xc00c8280a0?, 0xc0061a0ab0?})
        github.com/stashapp/stash/pkg/file/fs.go:66 +0x1e
github.com/stashapp/stash/pkg/file.(*scanJob).handleFolder.func1({0x14b44f33b410, 0xc0061a0ab0})
        github.com/stashapp/stash/pkg/file/scan.go:511 +0x16e
github.com/stashapp/stash/pkg/txn.withTxn({0x14b44f33b448, 0xc001a0e000}, {0x14b44f33b120, 0xc00036bb00}, 0xc003a57778, 0x80?, 0x0)
        github.com/stashapp/stash/pkg/txn/transaction.go:89 +0x177
github.com/stashapp/stash/pkg/txn.Retryer.WithTxn({{0x14b44f33b120?, 0xc00036bb00?}, 0xb0?, 0x0?}, {0x14b44f33b448, 0xc001a0e000}, 0xc003a57778)
        github.com/stashapp/stash/pkg/txn/transaction.go:156 +0xe6
github.com/stashapp/stash/pkg/file.(*scanJob).withTxn(...)
        github.com/stashapp/stash/pkg/file/scan.go:164
github.com/stashapp/stash/pkg/file.(*scanJob).handleFolder(0xc00c8280a0?, {0x14b44f33b448?, 0xc001a0e000?}, {0xc00adee420, {0x14b44f33cc40, 0x14b450371120}, {0x14b44f33e550, 0xc00ef9a000}})
        github.com/stashapp/stash/pkg/file/scan.go:497 +0xf4
github.com/stashapp/stash/pkg/file.(*scanJob).queueFiles.func1.(*scanJob).queueFileFunc.1({0xc00c8280a0, 0x9b}, {0x14b44f33b078, 0xc00addc500}, {0x0?, 0x0?})
        github.com/stashapp/stash/pkg/file/scan.go:282 +0x6f4
github.com/stashapp/stash/pkg/file.walkSym.func1({0xc00c828000?, 0x9a?}, {0x14b44f33b078, 0xc00addc500}, {0x0, 0x0})
        github.com/stashapp/stash/pkg/file/walk.go:79 +0x244
github.com/stashapp/stash/pkg/file.walkDir({0x14b44f33cc40, 0x14b450371120}, {0xc00c828000, 0x9b}, {0x14b44f33b078, 0xc00addc500}, 0xc003a57dd8)
        github.com/stashapp/stash/pkg/file/walk.go:112 +0x6c
github.com/stashapp/stash/pkg/file.walkDir({0x14b44f33cc40, 0x14b450371120}, {0xc00f280660, 0x56}, {0x14b44f33b078, 0xc00aa1b340}, 0xc003a57dd8)
        github.com/stashapp/stash/pkg/file/walk.go:136 +0x265
github.com/stashapp/stash/pkg/file.walkDir({0x14b44f33cc40, 0x14b450371120}, {0xc000e0c708, 0x16}, {0x14b44f33b078, 0xc00aa79140}, 0xc003a57dd8)
        github.com/stashapp/stash/pkg/file/walk.go:136 +0x265
github.com/stashapp/stash/pkg/file.walkDir({0x14b44f33cc40, 0x14b450371120}, {0xc007b3a8e0, 0xc}, {0x14b44f33b078, 0xc00118f040}, 0xc003a57dd8)
        github.com/stashapp/stash/pkg/file/walk.go:136 +0x265
github.com/stashapp/stash/pkg/file.walkDir({0x14b44f33cc40, 0x14b450371120}, {0xc000012320, 0x5}, {0x14b44f33ba08, 0xc000546430}, 0xc003a57dd8)
        github.com/stashapp/stash/pkg/file/walk.go:136 +0x265
github.com/stashapp/stash/pkg/file.fsWalk({0x14b44f33cc40, 0x14b450371120}, {0xc000012320, 0x5}, 0xc000d69dd8)
        github.com/stashapp/stash/pkg/file/walk.go:103 +0xdf
github.com/stashapp/stash/pkg/file.walkSym({0x14b44f33cc40?, 0x14b450371120?}, {0xc000012320?, 0xc001312060?}, {0xc000012320?, 0xc000546420?}, 0x10?)
        github.com/stashapp/stash/pkg/file/walk.go:81 +0x7c
github.com/stashapp/stash/pkg/file.symWalk(...)
        github.com/stashapp/stash/pkg/file/walk.go:86
github.com/stashapp/stash/pkg/file.(*scanJob).queueFiles.func1()
        github.com/stashapp/stash/pkg/file/scan.go:210 +0xe8
github.com/stashapp/stash/pkg/job.(*Progress).ExecuteTask(0xc001a0e050, {0x14b44e3d5f35, 0x16}, 0xc00118e340)
        github.com/stashapp/stash/pkg/job/progress.go:175 +0xb2
github.com/stashapp/stash/pkg/file.(*scanJob).queueFiles(0xc000176000, {0x14b44f33b448, 0xc001a0e000}, {0xc000bb2380, 0x1, 0x1})
        github.com/stashapp/stash/pkg/file/scan.go:208 +0xe9
github.com/stashapp/stash/pkg/file.(*scanJob).execute.func1()
        github.com/stashapp/stash/pkg/file/scan.go:182 +0x65
created by github.com/stashapp/stash/pkg/file.(*scanJob).execute in goroutine 9409
        github.com/stashapp/stash/pkg/file/scan.go:180 +0x215

I opened a ticket, but @feederbox826 indicated stash doesn’t support Btrfs. I use btrfs for cache in my unraid setup. Realistically, what is my path forward to getting stash working on unraid?

I think I may have found the actual bug - it’s not Btrfs-specific, it’s a Unicode handling issue in the case sensitivity check.

Looking at the error index out of range [155] with length 155 at fsutil/fs.go:37, this happens in IsFsPathCaseSensitive() where the code copies bytes from a case-flipped filename into a fixed-length byte array. The problem: when certain Unicode characters are uppercased or lowercased, they can change byte length in UTF-8.

I noticed your filenames are in Portuguese. Could you check if the file being scanned when it crashed contains any of these characters?

ı (Turkish dotless i) → I
ß (German eszett)
fi fl (ligatures)
Or any accented characters that might behave unexpectedly
To help confirm this bug, could you:

Share the exact filename that was being processed when it crashed (check the logs right before the panic)
Or try temporarily renaming files with unusual Unicode characters to ASCII-only names and see if the scan completes
If we can identify the specific character causing this, I can submit a PR to fix the byte-length handling in the IsFsPathCaseSensitive function. The fix would be straightforward - the code needs to handle the case where the flipped string has a different byte length than the original.

1 Like

BTW I also use unRAID and my cache drives are btrfs and I’ve never had this issue but my filenames are likely all ASCII

Thank for the second look!

It is hard to determine which file is the cause of the issue because of the way stash terminates. You get a few log lines above that may or may not be related. With that said, I was able to create a minimal unit test that seems to panic with the same error.

if you put the following into pkg/fsutil/fs_test.go:

package fsutil

import (
	"os"
	"path/filepath"
	"testing"
)

func TestIsFsPathCaseSensitive_UnicodeByteLength(t *testing.T) {
	// Ⱥ (U+023A) is 2 bytes in UTF-8
	// Its lowercase ⱥ (U+2C65) is 3 bytes in UTF-8
	// This causes index out of range when the code tries to copy the longer
	// flipped bytes into the original-length byte slice

	dir := t.TempDir()
	path := filepath.Join(dir, "Ⱥtest")

	// Create the directory so os.Stat succeeds
	if err := os.Mkdir(path, 0755); err != nil {
		t.Fatal(err)
	}

	// This will panic: index out of range
	_, _ = IsFsPathCaseSensitive(path)
}

and execute the command

go test ./pkg/fsutil/... -run TestIsFsPathCaseSensitive -v

It should recreate the error

If you create a folder named “Ⱥtest123” in your scan directory, it will crash, regardless of the filesystem.

Great! So we at least know how to get you running, and confirmed that you don’t have to make any drastic changes to your system. I’ll open a PR on Stash for the bugfix!

1 Like

It only seems to crash if the first character of the directory is one of the Unicode special cases, so I just need to scan my files for those and rename them.

Thank you @carrotwaxr !

I created a new ticket so we don’t lose track of this If you create a folder named Ⱥtest123 in your scan directory, stash will crash · Issue #6571 · stashapp/stash · GitHub

1 Like