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

solver: protect against nil dereference on uninitialized vertex #5606

Merged
merged 1 commit into from
Dec 20, 2024

Conversation

tonistiigi
Copy link
Member

Have a report of a panic on walkProvenance because the step does not have op initialized.

@tonistiigi
Copy link
Member Author

I tried to understand what case could trigger this but not entirely clear.

	/src/util/flightcontrol/flightcontrol.go:166 +0x536
created by github.com/moby/buildkit/util/flightcontrol.(*call[...]).wait in goroutine 352783
	/usr/local/go/src/sync/once.go:65
sync.(*Once).Do(...)
	/usr/local/go/src/sync/once.go:74 +0xc2
sync.(*Once).doSlow(0x1ea9be0?, 0xc003264008?)
	/src/util/flightcontrol/flightcontrol.go:122 +0x225
github.com/moby/buildkit/util/flightcontrol.(*call[...]).run(0x1ecfee0)
	/src/solver/llbsolver/bridge.go:331 +0x205
github.com/moby/buildkit/solver/llbsolver.(*resultProxy).Result.func2({0x1ec31c0, 0xc0051e76d0})
	/src/solver/llbsolver/provenance.go:276 +0xae
github.com/moby/buildkit/solver/llbsolver.captureProvenance({0x1ec31c0, 0xc0051e76d0}, {0x1ec8fb0, 0xc00a7fea20})
	/src/solver/jobs.go:726 +0x16c
github.com/moby/buildkit/solver.(*withProvenance).WalkProvenance(0xc00a7fea20, {0x1ec31c0, 0xc0051e76d0}, 0xc00e2d8210)
github.com/moby/buildkit/solver.(*Job).walkProvenance(0xc010dea9c0, {0x1ec31c0, 0xc0051e76d0}, {0x10?, {0x1ec6c00?, 0xc004915cc0?}}, 0xc00e2d8210, 0xc002761d58)
github.com/moby/buildkit/solver.(*Job).walkProvenance(0xc010dea9c0, {0x1ec31c0, 0xc0051e76d0}, {0x47?, {0x1ec6c00?, 0xc004915b40?}}, 0xc00e2d8210, 0xc002761d58)
github.com/moby/buildkit/solver.(*Job).walkProvenance(0xc010dea9c0, {0x1ec31c0, 0xc0051e76d0}, {0x47?, {0x1ec6c00?, 0xc004915ac0?}}, 0xc00e2d8210, 0xc002761d58)
github.com/moby/buildkit/solver.(*Job).walkProvenance(0xc010dea9c0, {0x1ec31c0, 0xc0051e76d0}, {0x47?, {0x1ec6c00?, 0xc004915a40?}}, 0xc00e2d8210, 0xc002761d58)
	/src/solver/jobs.go:746 +0x1e7
github.com/moby/buildkit/solver.(*Job).walkProvenance(0xc010dea9c0, {0x1ec31c0, 0xc0051e76d0}, {0x47?, {0x1ec6c00?, 0xc004915940?}}, 0xc00e2d8210, 0xc002761d58)
	/src/solver/jobs.go:737 +0x141
github.com/moby/buildkit/solver.(*Job).walkProvenance(0xc010dea9c0, {0x1ec31c0, 0xc0051e76d0}, {0x47?, {0x1ec6c00?, 0xc016774580?}}, 0xc00e2d8210, 0xc002761d58)
goroutine 352819 [running]:
[signal SIGSEGV: segmentation violation code=0x1 addr=0x50 pc=0xd82681]
panic: runtime error: invalid memory address or nil pointer dereference

There is no reproducer but in the logs I can see that right before this happened, there is a "merged edge" log for a mergeop step via COPY --link. So I assume most likely it is related. @sipsma @jedevc Can you understand a suitable codepath for this. I thought maybe there is unused input in cache calculation, so cache match can happen before all inputs have been validated but looking at the cache key digest that doesn't seem to be the case. I wonder if some double "merged edge" case can leave this uninitialized vertex.

T10:41:21Z" level=debug msg="merging edges" dest_index=0 dest_vertex_digest="sha256:0e28a8db3ac242f0cc944972fda8777038ffb171468595504510fc2f310ec230" dest_vertex_name="[mocks 1/1] LINK COPY --link --from= ..." source_edge_index=0 source_edge_vertex_digest="sha256:981953b5ced629c5b78a4a017b689cdb09f69dde577636c3e95abc5b9c78c65f" source_edge_vertex_name="[mocks 1/1] LINK COPY --link --from= ..."
T10:41:21Z" level=debug msg="merging edges" dest_index=0 dest_vertex_digest="sha256:0e28a8db3ac242f0cc944972fda8777038ffb171468595504510fc2f310ec230" dest_vertex_name="[mocks 1/1] LINK COPY --link --from= ..." source_edge_index=0 source_edge_vertex_digest="sha256:07e15da4045dd4c9f34182b2730cc320a2f6c8e2c652d37b98452e878a4f2ade" source_edge_vertex_name="[mocks 1/1] LINK COPY --link --from= ..."
T10:41:21Z" level=debug msg="merging edges" dest_index=0 dest_vertex_digest="sha256:d440c77db6f7f04fe7e8e159c95b3bcc8835ccd614a69165f79b58e6110c1065" dest_vertex_name="[mocks 1/1] COPY --link --from= ..." source_edge_index=0 source_edge_vertex_digest="sha256:c125388efc50f2da3f27d322611e1526814af1bea3d4af22ae7bde23f45e87f4" source_edge_vertex_name="[mocks 1/1] COPY --link --from= ..."
T10:41:21Z" level=debug msg="merging edges" dest_index=0 dest_vertex_digest="sha256:d440c77db6f7f04fe7e8e159c95b3bcc8835ccd614a69165f79b58e6110c1065" dest_vertex_name="[mocks 1/1] COPY --link --from= ..." source_edge_index=0 source_edge_vertex_digest="sha256:c02804635ad0d752057827b9500e8eadbd54efd42910f67e0b43cafd5dae04f4" source_edge_vertex_name="[mocks 1/1] COPY --link --from= ..."

We can also merge this and move this discussion to separate issue.

@AkihiroSuda AkihiroSuda merged commit 8e3c836 into moby:master Dec 20, 2024
96 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants