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

Can't run any podman command anymore - panic: runtime error: invalid memory address or nil pointer dereference #2184

Closed
dozenposture opened this issue Dec 3, 2024 · 8 comments · Fixed by #2185
Assignees
Labels

Comments

@dozenposture
Copy link

Discussed in containers/podman#24736

Originally posted by dozenposture December 2, 2024
I've used to have about 20 containers running without issues.
While trying to update an image, I've found podman can't execute any command anymore.

It really doesn't matter which command I try to run, I always get the following error message:

podman@host:~> podman info
ERRO[0000] Refreshing container a2dea400161ecc6b8440e937e4fb745a6bda8fc87056ddc14c4289dfc560c6da: acquiring lock 2 for container a2dea400161ecc6b8440e937e4fb745a6bda8fc87056ddc14c4289dfc560c6da: file exists
WARN[0000] Found incomplete layer "6d1aab23cceb2aa47ce43e610416609023b6a0dc576c7b383b3eccf30ab6efd6", deleting it
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x100 pc=0x5633e1fec837]

goroutine 1 [running]:
github.com/containers/storage.(*layerStore).load(0xc000460280, 0x1)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/vendor/github.com/containers/storage/layers.go:917 +0xff7
github.com/containers/storage.(*store).newLayerStore(0x3b?, {0xc000049ef0, 0x28}, {0xc00060f8c0, 0x3b}, {0x0, 0x0}, {0x5633e327af18, 0xc000146d80}, 0x0)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/vendor/github.com/containers/storage/layers.go:1156 +0x6e5
github.com/containers/storage.(*store).getLayerStoreLocked(0xc0005ac000)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/vendor/github.com/containers/storage/store.go:1125 +0x25d
github.com/containers/storage.(*store).getLayerStore(0xc0005ac000)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/vendor/github.com/containers/storage/store.go:1141 +0x8f
github.com/containers/storage.(*store).writeToAllStores(0xc0005ac000, 0xc0005244c0)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/vendor/github.com/containers/storage/store.go:1401 +0x4c
github.com/containers/storage.(*store).DeleteContainer(0x93?, {0xc0005dcb00?, 0x0?})
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/vendor/github.com/containers/storage/store.go:2703 +0x38
github.com/containers/podman/v5/libpod.(*storageService).DeleteContainer(0xc000116600, {0xc00060f500?, 0xc000260fc0?})
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/libpod/storage.go:177 +0x72
github.com/containers/podman/v5/libpod.(*Container).teardownStorage(0xc0004b8780)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/libpod/container_internal.go:603 +0x314
github.com/containers/podman/v5/libpod.(*Runtime).removeContainer(0xc000505180, {0x5633e3267d90, 0x5633e4032600}, 0xc0004b8780, {0x0, 0x1, 0x0, 0x0, 0x0, 0x0, ...})
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/libpod/runtime_ctr.go:981 +0x1888
github.com/containers/podman/v5/libpod.(*Runtime).refresh(0xc000505180, {0x5633e3267d90, 0x5633e4032600}, {0xc0005130c0, 0x1f})
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/libpod/runtime.go:871 +0x52d
github.com/containers/podman/v5/libpod.makeRuntime({0x5633e3267d90, 0x5633e4032600}, 0xc000505180)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/libpod/runtime.go:637 +0x1bce
github.com/containers/podman/v5/libpod.newRuntimeFromConfig({0x5633e3267d90, 0x5633e4032600}, 0xc0000c4008, {0xc000525660, 0x0, 0xa?})
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/libpod/runtime.go:213 +0x30e
github.com/containers/podman/v5/libpod.NewRuntime({0x5633e3267d90, 0x5633e4032600}, {0xc000525660, 0x0, 0x0})
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/libpod/runtime.go:171 +0x5a
github.com/containers/podman/v5/pkg/domain/infra.getRuntime({0x5633e3267d90, 0x5633e4032600}, 0xc0004a4100, 0xc000525898)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/pkg/domain/infra/runtime_libpod.go:228 +0x1edc
github.com/containers/podman/v5/pkg/domain/infra.GetRuntime.func1()
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/pkg/domain/infra/runtime_libpod.go:46 +0x65
sync.(*Once).doSlow(0x1c?, 0xc0004be400?)
	/usr/lib64/go/1.23/src/sync/once.go:76 +0xb4
sync.(*Once).Do(...)
	/usr/lib64/go/1.23/src/sync/once.go:67
github.com/containers/podman/v5/pkg/domain/infra.GetRuntime({0x5633e3267d90?, 0x5633e4032600?}, 0x5633e2a79cfa?, 0xe?)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/pkg/domain/infra/runtime_libpod.go:45 +0x55
github.com/containers/podman/v5/pkg/domain/infra.NewLibpodImageRuntime(0xc0005259b0?, 0xc0004bbab8?)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/pkg/domain/infra/runtime_proxy.go:24 +0x27
github.com/containers/podman/v5/pkg/domain/infra.NewImageEngine(0x5633e2a79cfa?)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/pkg/domain/infra/runtime_abi.go:31 +0x4b
github.com/containers/podman/v5/cmd/podman/registry.NewImageEngine(0x5633e3f3b3c0?, {0x5633e4009e00?, 0x9?, 0x5633e2da6e58?})
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/cmd/podman/registry/registry.go:50 +0x54
main.persistentPreRunE(0x5633e3f3b3c0, {0x5633e4032600, 0x0, 0x0})
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/cmd/podman/root.go:317 +0x6f9
github.com/spf13/cobra.(*Command).execute(0x5633e3f3b3c0, {0xc0000400d0, 0x0, 0x0})
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/vendor/github.com/spf13/cobra/command.go:956 +0x931
github.com/spf13/cobra.(*Command).ExecuteC(0x5633e3f23e00)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/vendor/github.com/spf13/cobra/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/vendor/github.com/spf13/cobra/command.go:1041
github.com/spf13/cobra.(*Command).ExecuteContext(...)
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/vendor/github.com/spf13/cobra/command.go:1034
main.Execute()
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/cmd/podman/root.go:116 +0xb4
main.main()
	/home/abuild/rpmbuild/BUILD/podman-5.3.1/cmd/podman/main.go:61 +0x4b2

I've browsed for similar issues and I've found something about lingering. The podman user has lingering enabled (since the beginning)

Can someone please help me out understanding what went wrong and how to fix this?
Thanks!

@Luap99
Copy link
Member

Luap99 commented Dec 3, 2024

WARN[0000] Found incomplete layer "6d1aab23cceb2aa47ce43e610416609023b6a0dc576c7b383b3eccf30ab6efd6", deleting it

Sounds like your storage is corrupted, so the easiest thing would be to remove the container storage and start from an empty storage again and recreate your containers.

Of course it would be good to understand what happend there and certainly it should never panic.
AFAICT https://github.com/containers/storage/blob/main/layers.go#L917 failed from the stack trace and that can only happen if the layer would be nil which means r.layers contains a nil layer somehow. Just reading the function there I do not see how this could happen though, we seem to access the layer in several places before so if it would be nil it should have failed much earlier.

Are you running rootless? If so what is the output of cat ~/.local/share/containers/storage/overlay-layers/layers.json?

@mtrmac @giuseppe Ideas?

@Luap99 Luap99 added the kind/bug label Dec 3, 2024
@Luap99
Copy link
Member

Luap99 commented Dec 3, 2024

Oh I see the issue in the c/storage code. While iterating r.layers r.deleteInternal() while remove the element from r.layers as such the slice is modified while we iterate over it which is not safe as we access the last element which no longer exists and we skip one layer.

storage/layers.go

Lines 1928 to 1930 in 3021f6a

r.layers = slices.DeleteFunc(r.layers, func(candidate *Layer) bool {
return candidate.ID == id
})

@dozenposture
Copy link
Author

dozenposture commented Dec 3, 2024

Thank you very much for your time looking into this issue, I really appreciated it.

This is the requested output (rather long, so I posted there not pollute this thread too much)

What I'm supposed to do exactly to get podman working again?
Asking specifically for a command. Please notice that I can't run any podman command without having that error message so I think I'll have to do something manual (just an assumption).

@Luap99
Copy link
Member

Luap99 commented Dec 3, 2024

If you don't need need the data delete ~/.local/share/containers/storage. Then just repull the images and recreate your containers.
Note that this dir also contains the data of names volumes in~/.local/share/containers/storage/volumes so if you have anything important backup this directory first before deleting anything.

Otherwise you need to wait for a patch from us to make it work again I think, or try to manually delete the incomplete layer ID from the json file but I don't know if this causes other bad things so just deleting all data seems safest to avoid any storage corruption.

@Luap99 Luap99 self-assigned this Dec 3, 2024
@Luap99 Luap99 transferred this issue from containers/podman Dec 3, 2024
@giuseppe
Copy link
Member

giuseppe commented Dec 3, 2024

good analysis! load() can't iterate r.layers and delete a layer from there.

If you've a patch, please tag me and I'll review it

Luap99 added a commit to Luap99/storage that referenced this issue Dec 3, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
@dozenposture
Copy link
Author

dozenposture commented Dec 3, 2024

Thanks everyone involved in this.
I don't think I use named volumes as I explicitly mount directories inside containers but ofc now I'm doubting ;)

I tried inspecting the ~/.local/share/containers/storage/volumes directory and it seems nothing important is there:

homeserver-prd:/home/podman/.local/share/containers/storage/volumes # ls -l ./*/*
./214cf4bfbb7df0d7ac2d80a34c7c35c3150dfe2f083d92d23a114ba42b679a8a/_data:
total 0

./a5f5e19fe028020baa1797607d39f52a903cf887c2b550b8734905a1aaa0b178/_data:
total 0

./e9411f2da8e781e5af85473de9301ede991cec983aef223804379d2a9d84abad/_data:
total 0
-rw-r--r--. 1 231072 231072 0 Sep 14 17:53 .not_mapped

just a .not_mapped file which is empty

I'm unsure now if I want to wait for the patch or delete what needs to be deleted :)

Luap99 added a commit to Luap99/storage that referenced this issue Dec 3, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Luap99 added a commit to Luap99/storage that referenced this issue Dec 3, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
@dozenposture
Copy link
Author

dozenposture commented Dec 3, 2024

@Luap99 I see that the proposed MR is already merged which is great and it was super fast!
When this change will reflect on podman though? Do I have to wait for the next version to be released?
(sorry for the potential stupid question but I've limited experience in software lifecycle).

@Luap99
Copy link
Member

Luap99 commented Dec 3, 2024

Yes you need to wait for the next version.
Generally we make new c/storage release for each podman minor release and the next podman minor release is planned for February so it will take a while most likely.
Maybe we can/should backport this fix to a patch release to get it out sooner but even there is no specific timeline so far.

kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 4, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 9, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 9, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 9, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 9, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 9, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Luap99 added a commit to Luap99/storage that referenced this issue Dec 9, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
(cherry picked from commit 99b0d2d)
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 9, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 9, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 10, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 10, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 10, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 10, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 11, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 11, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 11, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 11, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 11, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 11, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 11, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
kwilczynski pushed a commit to kwilczynski/storage that referenced this issue Dec 11, 2024
In go one should never modify a slice while also iterating over it at
the same time. This causes weird side effects as the underlying array
elements are shifted around without the range loop index knowing.
So if you delete a element the loop will then actually skip the next one
and theoretically access out of bounds on the last element which does
not panic but rather return the default zero type, nil here which then
causes the panic on layer.Flags == nil.

Here is a simple example to show the behavior:
func main() {
	slice := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	for _, num := range slice {
		if num == 5 {
			slice = slices.DeleteFunc(slice, func(n int) bool {
				return n == 5
			})
		}
		fmt.Println(num)
	}
}

The loop will not print 6, but then as last number it prints 0 (the
default zero type for an int).

Fixes containers#2184

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
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.

3 participants