Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(2438)

Issue 7304104: code review 7304104: runtime: allow cgo callbacks on non-Go threads (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
11 years, 3 months ago by rsc
Modified:
11 years, 2 months ago
Reviewers:
brainman, dvyukov
CC:
golang-dev, iant, minux1
Visibility:
Public.

Description

runtime: allow cgo callbacks on non-Go threads Fixes issue 4435.

Patch Set 1 #

Patch Set 2 : diff -r 864c37196df8 https://code.google.com/p/go/ #

Total comments: 20

Patch Set 3 : diff -r 9c3930413c1b https://code.google.com/p/go/ #

Patch Set 4 : diff -r 9c3930413c1b https://code.google.com/p/go/ #

Total comments: 13

Patch Set 5 : diff -r dd18b993ba95 https://go.googlecode.com/hg/ #

Patch Set 6 : diff -r dd18b993ba95 https://go.googlecode.com/hg/ #

Patch Set 7 : diff -r dd18b993ba95 https://go.googlecode.com/hg/ #

Patch Set 8 : diff -r dd18b993ba95 https://go.googlecode.com/hg/ #

Patch Set 9 : diff -r dd18b993ba95 https://go.googlecode.com/hg/ #

Patch Set 10 : diff -r dd18b993ba95 https://go.googlecode.com/hg/ #

Patch Set 11 : diff -r 7dc8e8103052 https://go.googlecode.com/hg/ #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+566 lines, -36 lines) Patch
M misc/cgo/test/cgo_test.go View 1 1 chunk +1 line, -0 lines 0 comments Download
A misc/cgo/test/cthread.go View 1 2 3 4 5 6 7 8 9 10 1 chunk +44 lines, -0 lines 0 comments Download
A misc/cgo/test/cthread_unix.c View 1 2 1 chunk +34 lines, -0 lines 0 comments Download
A misc/cgo/test/cthread_windows.c View 1 2 3 4 5 6 1 chunk +37 lines, -0 lines 0 comments Download
M src/pkg/runtime/asm_386.s View 1 2 3 4 5 6 7 8 3 chunks +56 lines, -12 lines 0 comments Download
M src/pkg/runtime/asm_amd64.s View 1 2 3 4 5 3 chunks +55 lines, -12 lines 0 comments Download
M src/pkg/runtime/asm_arm.s View 1 2 3 4 5 6 7 8 9 10 3 chunks +43 lines, -1 line 0 comments Download
M src/pkg/runtime/cgocall.c View 1 2 1 chunk +5 lines, -0 lines 0 comments Download
M src/pkg/runtime/os_windows.h View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
M src/pkg/runtime/proc.c View 1 2 3 4 5 6 4 chunks +219 lines, -10 lines 2 comments Download
M src/pkg/runtime/runtime.h View 1 2 3 4 5 6 7 3 chunks +5 lines, -1 line 0 comments Download
M src/pkg/runtime/sys_windows_386.s View 1 2 3 4 5 6 1 chunk +12 lines, -0 lines 0 comments Download
M src/pkg/runtime/sys_windows_amd64.s View 1 2 3 4 5 6 7 1 chunk +3 lines, -0 lines 0 comments Download
M src/pkg/runtime/thread_darwin.c View 1 2 3 4 5 6 1 chunk +7 lines, -0 lines 0 comments Download
M src/pkg/runtime/thread_freebsd.c View 1 2 3 4 5 6 1 chunk +7 lines, -0 lines 0 comments Download
M src/pkg/runtime/thread_linux.c View 1 2 3 4 5 6 1 chunk +7 lines, -0 lines 0 comments Download
M src/pkg/runtime/thread_netbsd.c View 1 2 3 4 5 6 1 chunk +7 lines, -0 lines 0 comments Download
M src/pkg/runtime/thread_openbsd.c View 1 2 3 4 5 6 1 chunk +7 lines, -0 lines 0 comments Download
M src/pkg/runtime/thread_plan9.c View 1 2 3 4 5 6 2 chunks +8 lines, -0 lines 0 comments Download
M src/pkg/runtime/thread_windows.c View 1 2 3 4 5 6 2 chunks +8 lines, -0 lines 0 comments Download

Messages

Total messages: 26
rsc
Hello golang-dev@googlegroups.com, I'd like you to review this change to https://code.google.com/p/go/
11 years, 3 months ago (2013-02-18 17:42:56 UTC) #1
iant
https://codereview.appspot.com/7304104/diff/2001/misc/cgo/test/cthread.c File misc/cgo/test/cthread.c (right): https://codereview.appspot.com/7304104/diff/2001/misc/cgo/test/cthread.c#newcode28 misc/cgo/test/cthread.c:28: pthread_create(&thread_id[i], &attr, addThread, &max); Why bother with attr and ...
11 years, 3 months ago (2013-02-18 20:10:50 UTC) #2
brainman
Your test fails on windows. # ..\misc\cgo\test # _/C_/go/root/misc/cgo/test ..\misc\cgo\test\cthread.c:5:21: fatal error: pthread.h: No such ...
11 years, 3 months ago (2013-02-18 22:33:14 UTC) #3
brainman
On 2013/02/18 22:33:14, brainman wrote: > USED(p);USED(n); Should do the same to thread_plan9.c. Alex
11 years, 3 months ago (2013-02-18 22:33:59 UTC) #4
minux1
this breaks ARM builds, I don't yet know why perhaps I made a wrong assumption ...
11 years, 3 months ago (2013-02-19 20:40:08 UTC) #5
rsc
PTAL Thanks for all the feedback. Alex, I split cthread.c into cthread_unix.c and cthread_windows.c. I ...
11 years, 3 months ago (2013-02-19 20:59:38 UTC) #6
brainman
windows/386 problems: This is the end of the build: ... # ..\misc\cgo\stdio # ..\misc\cgo\test # ...
11 years, 3 months ago (2013-02-20 00:21:42 UTC) #7
iant
On Tue, Feb 19, 2013 at 12:59 PM, <rsc@golang.org> wrote: >> >> What will happen ...
11 years, 3 months ago (2013-02-20 02:01:28 UTC) #8
iant
LGTM
11 years, 3 months ago (2013-02-20 02:56:54 UTC) #9
dvyukov
https://codereview.appspot.com/7304104/diff/6002/misc/cgo/test/cthread.go File misc/cgo/test/cthread.go (right): https://codereview.appspot.com/7304104/diff/6002/misc/cgo/test/cthread.go#newcode21 misc/cgo/test/cthread.go:21: func Add(x int) { also call runtime.Gosched() just in ...
11 years, 3 months ago (2013-02-20 07:45:35 UTC) #10
rsc
On Tue, Feb 19, 2013 at 9:01 PM, Ian Lance Taylor <iant@golang.org> wrote: > On ...
11 years, 2 months ago (2013-02-20 15:17:48 UTC) #11
rsc
On Tue, Feb 19, 2013 at 7:21 PM, <alex.brainman@gmail.com> wrote: > Program received signal SIGSEGV, ...
11 years, 2 months ago (2013-02-20 15:25:29 UTC) #12
rsc
https://codereview.appspot.com/7304104/diff/6002/src/pkg/runtime/proc.c File src/pkg/runtime/proc.c (right): https://codereview.appspot.com/7304104/diff/6002/src/pkg/runtime/proc.c#newcode807 src/pkg/runtime/proc.c:807: runtime·newextram(); On 2013/02/20 07:45:35, dvyukov wrote: > if(runtime·iscgo)? Done. ...
11 years, 2 months ago (2013-02-20 15:28:20 UTC) #13
dvyukov
On 2013/02/20 15:28:20, rsc wrote: > https://codereview.appspot.com/7304104/diff/6002/src/pkg/runtime/proc.c#newcode940 > src/pkg/runtime/proc.c:940: runtime·setmg(mp, mp->g0); > On 2013/02/20 07:45:35, ...
11 years, 2 months ago (2013-02-20 15:31:49 UTC) #14
rsc
On Wed, Feb 20, 2013 at 10:31 AM, <dvyukov@google.com> wrote: > However, then we change ...
11 years, 2 months ago (2013-02-20 15:36:37 UTC) #15
rsc
The current version of the CL has been revised and tested to work on: darwin/386 ...
11 years, 2 months ago (2013-02-20 22:02:11 UTC) #16
rsc
I played some more with ARM and got nowhere. Disabling the test on ARM and ...
11 years, 2 months ago (2013-02-20 22:41:57 UTC) #17
brainman
It is still crashing in misc/cgo/test on windows/386. But I have nothing to report yet. ...
11 years, 2 months ago (2013-02-20 22:43:30 UTC) #18
rsc
*** Submitted as https://code.google.com/p/go/source/detail?r=1d5a80b07916 *** runtime: allow cgo callbacks on non-Go threads Fixes issue 4435. ...
11 years, 2 months ago (2013-02-20 22:48:27 UTC) #19
rsc
On Wed, Feb 20, 2013 at 5:43 PM, <alex.brainman@gmail.com> wrote: > It is still crashing ...
11 years, 2 months ago (2013-02-20 22:50:03 UTC) #20
brainman
misc/cgo/test crashes sometimes. Perhaps, this will help you: (gdb) disas Dump of assembler code for ...
11 years, 2 months ago (2013-02-20 23:49:50 UTC) #21
dvyukov
I guess we need to mark usleep/osyield as #pragma textflag,7 (no split stack). On Thu, ...
11 years, 2 months ago (2013-02-21 05:04:32 UTC) #22
brainman
On 2013/02/21 05:04:32, dvyukov wrote: > I guess we need to mark usleep/osyield as #pragma ...
11 years, 2 months ago (2013-02-21 06:02:19 UTC) #23
dvyukov
https://codereview.appspot.com/7304104/diff/44001/src/pkg/runtime/proc.c File src/pkg/runtime/proc.c (right): https://codereview.appspot.com/7304104/diff/44001/src/pkg/runtime/proc.c#newcode944 src/pkg/runtime/proc.c:944: runtime·minit(); part of the problem was here minit() allocated ...
11 years, 2 months ago (2013-02-21 15:45:45 UTC) #24
dvyukov
https://codereview.appspot.com/7304104/diff/44001/src/pkg/runtime/proc.c File src/pkg/runtime/proc.c (right): https://codereview.appspot.com/7304104/diff/44001/src/pkg/runtime/proc.c#newcode944 src/pkg/runtime/proc.c:944: runtime·minit(); On 2013/02/21 15:45:45, dvyukov wrote: > part of ...
11 years, 2 months ago (2013-02-21 16:40:28 UTC) #25
dvyukov
11 years, 2 months ago (2013-02-21 16:55:08 UTC) #26
Message was sent while issue was closed.
On 2013/02/21 16:40:28, dvyukov wrote:
> https://codereview.appspot.com/7304104/diff/44001/src/pkg/runtime/proc.c
> File src/pkg/runtime/proc.c (right):
> 
>
https://codereview.appspot.com/7304104/diff/44001/src/pkg/runtime/proc.c#newc...
> src/pkg/runtime/proc.c:944: runtime·minit();
> On 2013/02/21 15:45:45, dvyukov wrote:
> > part of the problem was here
> > minit() allocated gsignal, but we've not yet called exitsyscall() so we are
> > potentially running concurrently with GC
> > 
> > it seems to be fixed by mpreinit() patch
> > but I still observe some crashes on linux on misc/cgo/test
> > still looks like corrupted heap
> 
> I've noticed that if I set GOGC=off the crash goes away, and if I set GOGC=1
it
> crashes more reliably.
> It probably means that we either allocate some memory concurrently with GC or
> some memory is not reachable.

OK, mystery solved. I will send a CL.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b