Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MemMapFs + afero.Walk -> infinite loop #185

Open
Ma124 opened this issue Dec 1, 2018 · 0 comments · May be fixed by #409
Open

MemMapFs + afero.Walk -> infinite loop #185

Ma124 opened this issue Dec 1, 2018 · 0 comments · May be fixed by #409
Labels

Comments

@Ma124
Copy link

Ma124 commented Dec 1, 2018

I have an MemMapFs with the following structure:

([]os.FileInfo) (len=1 cap=1) {
 (*mem.FileInfo)(0xc420098080)({
  FileData: (*mem.FileData)(0xc4200a6300)({
   Mutex: (sync.Mutex) {
    state: (int32) 0,
    sema: (uint32) 0
   },
   name: (string) (len=44) "abc.txt_a3171851-d16d-4b27-a790-1a4d3d4f221a",
   data: ([]uint8) (len=11 cap=16) {
    00000000  48 65 6c 6c 6f 20 47 6f  6c 70 21                 |Hello Golp!|
   },
   memDir: (mem.Dir) <nil>,
   dir: (bool) false,
   mode: (os.FileMode) T---------,
   modtime: (time.Time) 2018-12-01 09:58:08.052452176 +0100 CET m=+0.001122979
  })
 })
}

(One file named: abc.txt_a3171851-d16d-4b27-a790-1a4d3d4f221a)

So it should only call the walkFn once.

afero.Walk(i.Fs(), "/", func(path string, info os.FileInfo, err error) error {
	spew.Dump(info)
	return nil
})

But the above code results in:

(*mem.FileInfo)(0xc42000e088)({
 FileData: (*mem.FileData)(0xc420068300)({
  Mutex: (sync.Mutex) {
   state: (int32) 0,
   sema: (uint32) 0
  },
  name: (string) (len=1) "/",
  data: ([]uint8) <nil>,
  memDir: (*mem.DirMap)(0xc42000e078)((len=1) {
   (string) (len=44) "abc.txt_2d83e30d-bf11-4953-8ebb-fdb2e91235cc": (*mem.FileData)(0xc420068360)({
    Mutex: (sync.Mutex) {
     state: (int32) 0,
     sema: (uint32) 0
    },
    name: (string) (len=44) "abc.txt_2d83e30d-bf11-4953-8ebb-fdb2e91235cc",
    data: ([]uint8) (len=11 cap=16) {
     00000000  48 65 6c 6c 6f 20 47 6f  6c 70 21                 |Hello Golp!|
    },
    memDir: (mem.Dir) <nil>,
    dir: (bool) false,
    mode: (os.FileMode) T---------,
    modtime: (time.Time) 2018-12-01 09:53:37.422059676 +0100 CET m=+0.001065426
   })
  }),
  dir: (bool) true,
  mode: (os.FileMode) ----------,
  modtime: (time.Time) 0001-01-01 00:00:00 +0000 UTC
 })
})
(*mem.FileInfo)(0xc42000e100)({
 FileData: (*mem.FileData)(0xc420068600)({
  Mutex: (sync.Mutex) {
   state: (int32) 0,
   sema: (uint32) 0
  },
  name: (string) (len=1) "/",
  data: ([]uint8) <nil>,
  memDir: (*mem.DirMap)(0xc42000e0b0)((len=1) {
   (string) (len=1) "/": (*mem.FileData)(0xc420068600)(<already shown>)
  }),
  dir: (bool) true,
  mode: (os.FileMode) T---------,
  modtime: (time.Time) 2018-12-01 09:53:37.424199616 +0100 CET m=+0.003205398
 })
})
(*mem.FileInfo)(0xc420174010)({
 FileData: (*mem.FileData)(0xc420068720)({
  Mutex: (sync.Mutex) {
   state: (int32) 0,
   sema: (uint32) 0
  },
  name: (string) (len=1) "/",
  data: ([]uint8) <nil>,
  memDir: (*mem.DirMap)(0xc42000e110)((len=1) {
   (string) (len=1) "/": (*mem.FileData)(0xc420068720)(<already shown>)
  }),
  dir: (bool) true,
  mode: (os.FileMode) T---------,
  modtime: (time.Time) 2018-12-01 09:53:37.425307087 +0100 CET m=+0.004312958
 })
})
(*mem.FileInfo)(0xc420174070)({
 FileData: (*mem.FileData)(0xc42017e0c0)({
  Mutex: (sync.Mutex) {
   state: (int32) 0,
   sema: (uint32) 0
  },
  name: (string) (len=1) "/",
  data: ([]uint8) <nil>,
  memDir: (*mem.DirMap)(0xc420174020)((len=1) {
   (string) (len=1) "/": (*mem.FileData)(0xc42017e0c0)(<already shown>)
  }),
  dir: (bool) true,
  mode: (os.FileMode) T---------,
  modtime: (time.Time) 2018-12-01 09:53:37.426633396 +0100 CET m=+0.005639164
 })
})
// It goes on forever

So the walkFn is called once for the file and an infinite amount of times for /.
(It doesn't work with . instead of / either)

@0xmichalis 0xmichalis added the bug label Mar 27, 2020
@erstam erstam linked a pull request Nov 14, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants