Skip to content

Conversation

@zhouhao3
Copy link

@zhouhao3 zhouhao3 commented Jul 6, 2017

When I execute the create command, there was an error, but there was no error when making the test. So need to improve the test content, and fix the error.

Signed-off-by: zhouhao [email protected]

@zhouhao3 zhouhao3 force-pushed the image-test-fix branch 2 times, most recently from b7b5597 to 7ca85c1 Compare July 6, 2017 05:55
@zhouhao3
Copy link
Author

@opencontainers/image-tools-maintainers PTAL

@zhouhao3 zhouhao3 force-pushed the image-test-fix branch 2 times, most recently from 18b4105 to 1747903 Compare July 24, 2017 05:44
@zhouhao3 zhouhao3 changed the title image_test: Improve the test content image: Improve the test content and fix the error Jul 24, 2017
@zhouhao3
Copy link
Author

@xiekeyang @coolljt0725 @cyphar @vbatts PTAL

@cyphar
Copy link
Member

cyphar commented Jul 24, 2017

What was the error? Can you include it in the commit message that fixes said error?

@zhouhao3
Copy link
Author

zhouhao3 commented Jul 25, 2017

The following error occurs when the create command is executed:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x48ef43]
goroutine 19 [running]:
panic(0x808060, 0xc420010130)
/home/zhouhao/go/src/runtime/panic.go:500 +0x1ae
testing.tRunner.func1(0xc4200932c0)
/home/zhouhao/go/src/testing/testing.go:579 +0x474
panic(0x808060, 0xc420010130)
/home/zhouhao/go/src/runtime/panic.go:458 +0x271
github.com/opencontainers/image-tools/image.(*config).runtimeSpec(0xc420676240, 0x85e3f6, 0x6, 0xc4201d3920, 0x1a, 0x0)
github.com/opencontainers/image-tools/image/_test/_obj_test/config.go:94 +0x1b3
github.com/opencontainers/image-tools/image.createBundle(0xa2f7e0, 0xc4204fc090, 0xc420543b20, 0xc4200df2a0, 0x13, 0x85e3f6, 0x6, 0x0, 0x0)
github.com/opencontainers/image-tools/image/_test/_obj_test/image.go:414 +0x318
github.com/opencontainers/image-tools/image.createRuntimeBundle(0xa2f7e0, 0xc4204fc090, 0xc4200df2a0, 0x13, 0x85e384, 0x6, 0x85e3f6, 0x6, 0x0, 0x0, ...)
github.com/opencontainers/image-tools/image/_test/_obj_test/image.go:348 +0x9ce
github.com/opencontainers/image-tools/image.CreateRuntimeBundleLayout(0xc4200df180, 0x16, 0xc4200df2a0, 0x13, 0x85e384, 0x6, 0x85e3f6, 0x6, 0x0, 0x0, ...)

Because there is no non-empty check on the optional fields in config.go.

image/config.go Outdated
if err != nil {
return nil, errors.New("config.User: unsupported gid format")
if len(s.Process.Args) == 0 {
s.Process.Args = append(s.Process.Args, "sh")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we make the assumption that sh is always available in a container?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Args has at least one value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is not what I asked.

Not all containers are going to have a sh binary present. Adding this, when it might not even exist, will certainly result in failure. This is also never mentioned in the specification. In the case that no args are provided, it should just not be set.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing this is outside the scope of this PR. I've filed #166.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevvooe If there are no other questions, can we merge this patch first and then discuss the sh problem? Because if you don't merge this, the create function won't work.

@stevvooe
Copy link
Contributor

A good title for this PR and the commit might be "image: avoid panic on nil fields when converting".

Also, please take the time to squash this into a single commit.

@zhouhao3
Copy link
Author

updated, PTAL.

@zhouhao3 zhouhao3 changed the title image: Improve the test content and fix the error image: avoid panic on nil fields when converting Jul 26, 2017
image/config.go Outdated
s.Process.Cwd = "/"
if c.Config.WorkingDir != "" {
s.Process.Cwd = c.Config.WorkingDir
if s.Root != nil {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not a right fix. Default Root is nil in Spec, we should initialize it as s.Root= &specs.Root{}, also same to Process.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, thanks.

The following error occurs when the create command is executed:

    panic: runtime error: invalid memory address or nil pointer dereference [recovered]
    panic: runtime error: invalid memory address or nil pointer dereference
    [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x48ef43]
    goroutine 19 [running]:
    panic(0x808060, 0xc420010130)
    /home/zhouhao/go/src/runtime/panic.go:500 +0x1ae
    testing.tRunner.func1(0xc4200932c0)
    /home/zhouhao/go/src/testing/testing.go:579 +0x474
    panic(0x808060, 0xc420010130)
    /home/zhouhao/go/src/runtime/panic.go:458 +0x271
    ...

Because there is no non-empty check on the optional fields in config.go.

Signed-off-by: zhouhao <[email protected]>
@zhouhao3 zhouhao3 force-pushed the image-test-fix branch 2 times, most recently from dd70fea to bb4fdfe Compare August 4, 2017 07:15
@stevvooe
Copy link
Contributor

stevvooe commented Aug 8, 2017

LGTM

Approved with PullApprove

1 similar comment
@coolljt0725
Copy link
Member

coolljt0725 commented Aug 8, 2017

LGTM

Approved with PullApprove

@coolljt0725 coolljt0725 merged commit 1ddba1b into opencontainers:master Aug 8, 2017
@zhouhao3 zhouhao3 deleted the image-test-fix branch August 14, 2017 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants