upspin: cmd/upspinfs: panic when coping files

OS: MacOS Sequoia

What happened: I recreate my upspin server with a different storage once again and was coping my backups to the new server. Something like

$ cp -r ./Books ~/u/user@example.com

It copied some files and than returned an error (I don’t remember the error) that I thought my backup were corrupted but that was not the case.

After looking the upspinfs logs it was a nil pointer dereference.

The logs: issue.log

The culprit seems to be this part of code. In some cases the *DirEntry in line 592 is nil: https://github.com/upspin/upspin/blob/209f0c9c37d75884d380fb31543b770a8d2e0200/cmd/upspinfs/cache.go#L562-L592

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 18 (8 by maintainers)

Commits related to this issue

Most upvoted comments

As usual, my first attept at pushing it back was from a now dead branch, so I have yet another change to that branch. Now pushed it to master I believe correctly. I can’t not use git for years and expect to do anythign right.

On Sat, Dec 21, 2024 at 10:21 PM Rodrigo Schio @.***> wrote:

It worked!

I couldn’t reproduce the problem naturally, but I was able to force a reproduction.

When the code reaches this part my modified upspinfs sleeps for 5 seconds and ask you to disable the internet. Without internet it reaches the buggy path when the created file is a ._file

e.g: $ cp hello.txt @.***/Debug/._hello.txt

log.Info.Printf(“************** disable your internet *****************”) time.Sleep(5 * time.Second)

// Use the client library to write it back. Try multiple times on error. var de upspin.DirEntry for tries := 0; ; tries++ { log.Info.Printf("************* inside tries ***“) de, err = cf.c.client.PutSequenced(n.uname, n.seq, cleartext) if err == nil { n.seq = de.Sequence cf.attachDirEntry(n.f.config, de, true) n.attr.Mtime = de.Time.Go() break } if tries > 5 || !strings.Contains(err.Error(), “unreachable”) { log.Info.Printf(” tries >5 || !strings.Contains(err.Error(), unreachable) ***“) if isXattrFile(n.uname) { log.Info.Printf(” inside buggy path *****************") // A hack so every server doesn’t have to handle // xattr files. We pretend the Put worked and // increase the ref count for the cached version // so that the xattr at least lasts as long as // upspinfs stays up. Not perfect but keeps // macOS finder happy. // TODO(p): this might be improved by constraining // to fewer error types. cf.file.Pin() // break // // quit trying to write it back. cf.dirty = false return nil } return errors.E(op, err) } time.Sleep(100 * time.Millisecond) }

// Rename it to reflect the actual reference in the store so that new // opens will find the cached version. cdir, fname := cf.c.cacheName(de)

reproducing the problem without your fix: modified_old.log https://github.com/user-attachments/files/18220936/modified_old.log

reproducing the problem with your fix: modified_new.log https://github.com/user-attachments/files/18220939/modified_new.log

— Reply to this email directly, view it on GitHub https://github.com/upspin/upspin/issues/670#issuecomment-2558347289, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABJTMPIEXNCX2KTCI3XFLYT2GZK7RAVCNFSM6AAAAABUBASRSKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNJYGM2DOMRYHE . You are receiving this because you commented.Message ID: @.***>