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

runtime: expand error for signal received on non-Go thread #4048

Closed
rogpeppe opened this issue Sep 6, 2012 · 12 comments
Closed

runtime: expand error for signal received on non-Go thread #4048

rogpeppe opened this issue Sep 6, 2012 · 12 comments
Milestone

Comments

@rogpeppe
Copy link
Contributor

rogpeppe commented Sep 6, 2012

We're seeing this problem occasionally, and it might
be useful if the message contained the number of the signal
that has actually been received.

Unfortunately I don't seem to be able to create a piece of
code that can reliably reproduce the problem, which means that
any fix would be untested.

I've attached my attempt at doing so anyway.

Attachments:

  1. tst.go (737 bytes)
@minux
Copy link
Member

minux commented Sep 6, 2012

Comment 1:

if you simply want to trigger that message, you can use this:
package main
/*
#include <pthread.h>
void *
pauser(void *x) {
        *(int *)0 = 1;
    return 0;
}
void
startThread(void) {
    pthread_t p;
    pthread_create(&p, 0, pauser, 0);
}
*/
import "C"
func main() {
    C.startThread()
    for {}
}

@minux
Copy link
Member

minux commented Sep 6, 2012

Comment 2:

the reason why we haven't already implement your suggestion is that
when we received a signal on non-Go-created thread, we don't have
access to m & g so we can't reliably call runtime.printf.
i agree we can do better.

Status changed to Accepted.

@adonovan
Copy link
Member

adonovan commented Sep 7, 2012

Comment 3:

Attached is my attempt at a fix but the call to findnull (strlen) on the signal name
string causes it to exceed the nosplit stack limit check.
Three ways to proceed:
(a) expand the amount stack available.  Seems like a sledgehammer to crack a nut.
(b) compute strlen of the string literals and save it as another column in sigtab.
(b) do nothing (or wait till the compiler's register allocation improves).
Go experts: please advise.

Attachments:

  1. 4048.patch (4957 bytes)

@ianlancetaylor
Copy link
Member

Comment 4:

This is a case that will approximately never happen.  Since the argument is not nil,
findnull is two lines long.  I would just inline it.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 5:

Labels changed: added priority-later, removed priority-triage.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 6:

Labels changed: added go1.1.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 7:

Alan, your patch looks fine except that it should make sure 0 <= sig && sig <
nelem(runtime·sigtab) before doing the print (and inline findnull as Ian said). Want to
send a CL?

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 8:

Labels changed: added size-m.

@adonovan
Copy link
Member

Comment 9:

There's not enough space in the frame for even one extra pointer variable, so inlining
findnull doesn't help.

@minux
Copy link
Member

minux commented Jan 31, 2013

Comment 10:

yeah, i also tried to fix this issue, and stuck by the same obstacle.
can we use a function pointer to work around the linker's check of
maximum stack frame for non-split functions?
as the function in question should always be called on a OS thread
stack, so the stack space is plenty.

@adonovan
Copy link
Member

Comment 11:

It worked!
https://golang.org/cl/7232066

@adonovan
Copy link
Member

Comment 12:

This issue was closed by revision e49f945.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants