Skip to content

TestCatchAll, TestStopCatch: remove unneeded goroutine#40496

Merged
AkihiroSuda merged 1 commit intomoby:masterfrom
thaJeztah:locally_scope_variable
Apr 7, 2020
Merged

TestCatchAll, TestStopCatch: remove unneeded goroutine#40496
AkihiroSuda merged 1 commit intomoby:masterfrom
thaJeztah:locally_scope_variable

Conversation

@thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Feb 10, 2020

relates to #40353

@thaJeztah thaJeztah mentioned this pull request Feb 10, 2020
20 tasks
@thaJeztah thaJeztah marked this pull request as ready for review February 10, 2020 20:32
@thaJeztah
Copy link
Member Author

#40353 passes with this change at least, so moving out of draft 😅

@cpuguy83
Copy link
Member

I don't see what race this is fixing.

@cpuguy83
Copy link
Member

For that matter sending the signal should be async anyway. I'm not sure we need the goroutine.

@thaJeztah
Copy link
Member Author

Perhaps I'm completely off, but signal was used in the go func and could be pointing to a different value after it's started, but you're right that this probably doesn't solve the issue

@cpuguy83
Copy link
Member

signal is defined inside the loop, therefore each loop iteration gets a new definition.
If it was var signal string outside of the loop (or, for instance the goroutine was using sigStr) then it would be overwritten in the goroutine.

@cpuguy83
Copy link
Member

In any case, I think this test will work without the goroutine (and no need for sleep).

@thaJeztah
Copy link
Member Author

or, for instance the goroutine was using sigStr

you're right; I was thinking about that case, but it's not the problem. I can update to remove the goroutine 👍

@thaJeztah
Copy link
Member Author

LOL; interesting; looks like Goland runs tests in an interesting way for this file, and adds both linux and darwin build-tags;

GOROOT=/usr/local/Cellar/go/1.13/libexec #gosetup
GOPATH=/Users/sebastiaan/go #gosetup
/usr/local/Cellar/go/1.13/libexec/bin/go test -c -tags "darwin linux" -o /private/var/folders/c_/vjh56sc12fd2b_q2n02_lt140000gn/T/___TestCatchAll_in_github_com_docker_docker_pkg_signal github.com/docker/docker/pkg/signal #gosetup
# runtime/internal/sys
/usr/local/Cellar/go/1.13/libexec/src/runtime/internal/sys/zgoos_linux.go:8:7: GOOS redeclared in this block
	previous declaration at /usr/local/Cellar/go/1.13/libexec/src/runtime/internal/sys/zgoos_darwin.go:7:14

@thaJeztah thaJeztah force-pushed the locally_scope_variable branch from 2e6cc38 to af2a11f Compare February 14, 2020 23:42
@thaJeztah thaJeztah changed the title Fix race condition in TestCatchAll TestCatchAll, TestStopCatch: remove unneeded goroutine Feb 14, 2020
@thaJeztah
Copy link
Member Author

Updated 👍

Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

LGTM

@thaJeztah
Copy link
Member Author

@AkihiroSuda @tiborvass LGTY?

@thaJeztah
Copy link
Member Author

ping @tiborvass @kolyshkin PTAL

@AkihiroSuda AkihiroSuda merged commit ff9fa7b into moby:master Apr 7, 2020
@kolyshkin
Copy link
Contributor

I was just looking into this code today (not the tests). These functions (together with their test cases) should be moved to docker/cli, as they are only used for cli.

@thaJeztah thaJeztah deleted the locally_scope_variable branch April 7, 2020 06:36
@elboulangero
Copy link
Contributor

elboulangero commented Apr 14, 2020

I'm building the docker branch 19.03 against golang 1.14.2, and I still observe this test failure after applying this patch:

=== RUN   TestCatchAll
    TestCatchAll: signal_linux_test.go:32: assertion failed: urgent I/O condition (string) != hangup (string)
    TestCatchAll: signal_linux_test.go:32: assertion failed: hangup (string) != child exited (string)
    TestCatchAll: signal_linux_test.go:32: assertion failed: child exited (string) != illegal instruction (string)
    TestCatchAll: signal_linux_test.go:32: assertion failed: illegal instruction (string) != floating point exception (string)
    TestCatchAll: signal_linux_test.go:32: assertion failed: floating point exception (string) != child exited (string)
--- FAIL: TestCatchAll (0.00s)

Is the patch supposed to address this issue in the end?

(if the answer is no, you might want to update the name of the issue at #40353 (comment))

@thaJeztah
Copy link
Member Author

This is only in the master branch, not in the 19.03 branch. Neither branches currently work with Go 1.14 (and there's still known issues in containerd and runc as well with compatibility with Go 1.14); Id recommend sticking to Go 1.13 to build for now

@elboulangero
Copy link
Contributor

Thanks for the quick reply!

This is only in the master branch, not in the 19.03 branch

Yep sure, what I meant is that I observe this test failure on the 19.03 branch, and applying this patch doesn't fix it. It looks like the original intention of this PR was to fix a race, but then it became a maintenance commit, so I just wanted to clarify that the test failure persists after this commit.

@thaJeztah
Copy link
Member Author

Ah, gotcha, thanks! I haven't continued to look at Go 1.14 compatibility (because I know some "lower level" projects (containerd, runc) still had to work on some fixes and it didn't have the highest priority.

@thaJeztah thaJeztah added this to the 20.03.0 milestone Apr 15, 2020
sir-xw pushed a commit to openkylin/docker.io that referenced this pull request Apr 22, 2025
Issue mentioned upstream at <moby/moby#40353>,
there was a tentative fix at <moby/moby#40496>,
but the issue is still present.

    === Failed
    === FAIL: pkg/signal TestCatchAll (0.00s)
      signal_linux_test.go:32: assertion failed: urgent I/O condition (string) != hangup (string)
      signal_linux_test.go:32: assertion failed: hangup (string) != child exited (string)
      signal_linux_test.go:32: assertion failed: child exited (string) != illegal instruction (string)
      signal_linux_test.go:32: assertion failed: illegal instruction (string) != floating point exception (string)
      signal_linux_test.go:32: assertion failed: floating point exception (string) != child exited (string)


Gbp-Pq: Name test--skip-pkg-signal-flaky-tests.patch
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.

5 participants