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: build broken on OpenBSD #4878

Closed
bradfitz opened this issue Feb 22, 2013 · 7 comments
Closed

runtime: build broken on OpenBSD #4878

bradfitz opened this issue Feb 22, 2013 · 7 comments
Milestone

Comments

@bradfitz
Copy link
Contributor

Started being broken at:

1d5a80b07916 runtime: allow cgo callbacks on non-Go threads

Failure is:
http://build.golang.org/log/c3187a74c393039646419ef52f554e4824672c18
...
...
# ../misc/cgo/test
# testmain
/home/builder/gobuilder/openbsd-amd64-1d5a80b07916/go/pkg/tool/openbsd_amd64/6l: symbol
is both dynimport and dynexport pthread_create
FAIL    _/home/builder/gobuilder/openbsd-amd64-1d5a80b07916/go/misc/cgo/test [build failed]


From minux:

   we should fix the linker.

   background:
   OpenBSD doesn't yet support PT_TLS in ELF program header so we have to
   hook libpthread's pthread_create and create allocate TLS storage for m&g.
   Thus runtime/cgo exports the symbol pthread_create.

   the new misc/cgo/test/cthread_unix.c imports pthread_create, and causing the
   linker error.
@bradfitz
Copy link
Contributor Author

Comment 1:

Labels changed: added os-openbsd, removed priority-triage.

@rsc
Copy link
Contributor

rsc commented Feb 22, 2013

Comment 2:

It is possible that the new "use the host linker" support will take care of this
automatically. 
Too bad we can't light a fire under the OpenBSD guys to bring their operating system
into the 21st century.

@rsc
Copy link
Contributor

rsc commented Feb 22, 2013

Comment 3:

It is possible to tell whether tcp_fixup has run already. Check whether the first word
of the TCP points at itself.
Before tcp_fixup, it does. Afterward, it does not. The signal handler can use this to
decide whether there is a valid m and g worth loading. The new "run Go on C threads"
code can do the same.
That should eliminate the need for the pthread_create hook hack. Let's do that anyway.
I've never felt completely comfortable trying to replace pthread_create.

@rsc
Copy link
Contributor

rsc commented Feb 22, 2013

Comment 4:

Also, this is probably a mistake: 
    // The main thread TCB is a static allocation - do not try to free it.
    if(!mainthread)
        free(oldtcb);
The pointer I was talking about that points at itself is the first word of the main tcb.
In the copy, it still points at the old tcb. Freeing the old tcb creates a dangling
pointer. I don't know what looks at it, but probably something does. Or if nothing does,
we could set that word to something faulty like 1 to mark that it is a "Go" tcb.

@minux
Copy link
Member

minux commented Feb 23, 2013

Comment 5:

Hi Russ,
    amd64 and i386 port of OpenBSD use the large variant of TCB which has the self pointer
you described
(http://www.openbsd.org/cgi-bin/cvsweb/src/sys/arch/i386/include/tcb.h?rev=HEAD;content-type=text%2Fplain
and
http://www.openbsd.org/cgi-bin/cvsweb/src/sys/arch/amd64/include/tcb.h?rev=HEAD;content-type=text%2Fplain)
    however arm uses the small tls (http://www.openbsd.org/cgi-bin/cvsweb/src/sys/arch/arm/include/tcb.h?rev=HEAD;content-type=text%2Fplain).
See here for definition of tcb:
http://www.openbsd.org/cgi-bin/cvsweb/src/lib/librthread/tcb.h?rev=HEAD;content-type=text%2Fplain
i searched /usr/src for __tcb_self, and i don't find any explicit references to it in
the code,
@jsing, do you agree with the plan to use a bad __tcb_self to signify a Go tcb?

@minux
Copy link
Member

minux commented Mar 1, 2013

Comment 6:

Issue #4957 has been merged into this issue.

@minux
Copy link
Member

minux commented Mar 11, 2013

Comment 7:

This issue was closed by revision 960d708.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1maybe 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

4 participants