{"action":"closed","issue":{"url":"https://api.github.com/repos/golang/go/issues/17641","repository_url":"https://api.github.com/repos/golang/go","labels_url":"https://api.github.com/repos/golang/go/issues/17641/labels{/name}","comments_url":"https://api.github.com/repos/golang/go/issues/17641/comments","events_url":"https://api.github.com/repos/golang/go/issues/17641/events","html_url":"https://github.com/golang/go/issues/17641","id":185801659,"number":17641,"title":"runtime: signal handling: sigfwd calls C handlers with improper alignment","user":{"login":"bcmills","id":5200974,"avatar_url":"https://avatars.githubusercontent.com/u/5200974?v=3","gravatar_id":"","url":"https://api.github.com/users/bcmills","html_url":"https://github.com/bcmills","followers_url":"https://api.github.com/users/bcmills/followers","following_url":"https://api.github.com/users/bcmills/following{/other_user}","gists_url":"https://api.github.com/users/bcmills/gists{/gist_id}","starred_url":"https://api.github.com/users/bcmills/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcmills/subscriptions","organizations_url":"https://api.github.com/users/bcmills/orgs","repos_url":"https://api.github.com/users/bcmills/repos","events_url":"https://api.github.com/users/bcmills/events{/privacy}","received_events_url":"https://api.github.com/users/bcmills/received_events","type":"User","site_admin":false},"labels":[{"id":373399998,"url":"https://api.github.com/repos/golang/go/labels/NeedsFix","name":"NeedsFix","color":"ededed","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/golang/go/milestones/38","html_url":"https://github.com/golang/go/milestones/Go1.8","labels_url":"https://api.github.com/repos/golang/go/milestones/38/labels","id":1709363,"number":38,"title":"Go1.8","description":"","creator":{"login":"griesemer","id":8528975,"avatar_url":"https://avatars.githubusercontent.com/u/8528975?v=3","gravatar_id":"","url":"https://api.github.com/users/griesemer","html_url":"https://github.com/griesemer","followers_url":"https://api.github.com/users/griesemer/followers","following_url":"https://api.github.com/users/griesemer/following{/other_user}","gists_url":"https://api.github.com/users/griesemer/gists{/gist_id}","starred_url":"https://api.github.com/users/griesemer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/griesemer/subscriptions","organizations_url":"https://api.github.com/users/griesemer/orgs","repos_url":"https://api.github.com/users/griesemer/repos","events_url":"https://api.github.com/users/griesemer/events{/privacy}","received_events_url":"https://api.github.com/users/griesemer/received_events","type":"User","site_admin":false},"open_issues":185,"closed_issues":510,"state":"open","created_at":"2016-04-15T16:30:23Z","updated_at":"2016-11-01T17:37:59Z","due_on":"2017-01-31T00:00:00Z","closed_at":null},"comments":2,"created_at":"2016-10-27T23:03:38Z","updated_at":"2016-11-01T17:37:59Z","closed_at":"2016-11-01T17:37:58Z","body":"go version go1.7.3 linux/amd64\n### What did you do?\n\nIn `misc/cgo/testcarchive/main2.c`, add a function call within the signal handler which generates an instruction that requires proper alignment.  Calling a varargs function with a floating-point parameter seems to suffice:\n\n``` diff\nbcmills:~/src/go.googlesource.com/go/misc/cgo/testcarchive$ git diff main2.c\ndiff --git a/misc/cgo/testcarchive/main2.c b/misc/cgo/testcarchive/main2.c\nindex 3726977..c814047 100644\n--- a/misc/cgo/testcarchive/main2.c\n+++ b/misc/cgo/testcarchive/main2.c\n@@ -7,8 +7,10 @@\n\n #include <setjmp.h>\n #include <signal.h>\n+#include <stdarg.h>\n #include <stddef.h>\n #include <stdio.h>\n+#include <stdint.h>\n #include <stdlib.h>\n #include <string.h>\n #include <sys/types.h>\n@@ -46,11 +48,19 @@ static void ioHandler(int signo, siginfo_t* info, void* ctxt) {\n static jmp_buf jmp;\n static char* nullPointer;\n\n+static void callWithVarargs(void* dummy, ...) {\n+       va_list args;\n+       va_start(args, dummy);\n+       va_end(args);\n+}\n+\n // Signal handler for SIGSEGV on a C thread.\n static void segvHandler(int signo, siginfo_t* info, void* ctxt) {\n        sigset_t mask;\n        int i;\n\n+       callWithVarargs(\"dummy arg\", 3.1415);\n+\n        if (sigemptyset(&mask) < 0) {\n                die(\"sigemptyset\");\n        }\n```\n\nEnable the race-detector in the corresponding test:\n\n``` diff\nbcmills:~/src/go.googlesource.com/go/misc/cgo/testcarchive$ git diff carchive_test.go\ndiff --git a/misc/cgo/testcarchive/carchive_test.go b/misc/cgo/testcarchive/carchive_test.go\nindex 4999929..30334cf 100644\n--- a/misc/cgo/testcarchive/carchive_test.go\n+++ b/misc/cgo/testcarchive/carchive_test.go\n@@ -198,7 +198,7 @@ func TestEarlySignalHandler(t *testing.T) {\n                os.RemoveAll(\"pkg\")\n        }()\n\n-       cmd := exec.Command(\"go\", \"build\", \"-buildmode=c-archive\", \"-o\", \"libgo2.a\", \"libgo2\")\n+       cmd := exec.Command(\"go\", \"build\", \"-race\", \"-buildmode=c-archive\", \"-o\", \"libgo2.a\", \"libgo2\")\n        cmd.Env = gopathEnv\n        if out, err := cmd.CombinedOutput(); err != nil {\n                t.Logf(\"%s\", out)\n```\n\nThen, run the test:\n\n```\nbcmills:~/src/go.googlesource.com/go/misc/cgo/testcarchive$ go test -v -test.run=TestEarlySignalHandler ./carchive_test.go\n=== RUN   TestEarlySignalHandler\n--- FAIL: TestEarlySignalHandler (6.46s)\n        carchive_test.go:215:\n        carchive_test.go:216: signal: segmentation fault (core dumped)\nFAIL\nexit status 1\nFAIL    command-line-arguments  7.259s\n```\n### What did you expect to see?\n\nThe test should pass.\n### What did you see instead?\n\nThe test fails due to a second SIGSEGV within the first SIGSEGV handler call.  The source of the second SIGSEGV is a `movaps` instruction which requires the stack to be properly 16-byte aligned.\n"}}
{"actor":{"display_login":"gopherbot"}}