1
0
mirror of https://github.com/golang/go synced 2024-10-03 06:11:21 -06:00
Commit Graph

268 Commits

Author SHA1 Message Date
Russ Cox
774333685e runtime: fix scheduling bug - world wasn't stopping
Fixes #886.

R=r
CC=golang-dev
https://golang.org/cl/1667051
2010-06-29 17:47:27 -07:00
Alex Brainman
059c7ba996 runtime: fix windows build
R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/1747041
2010-06-29 07:12:14 -07:00
Ian Lance Taylor
807605d0fc Only catch all signals if os/signal package imported.
Fixes #776.

R=rsc
CC=golang-dev
https://golang.org/cl/1745041
2010-06-28 17:14:17 -07:00
Russ Cox
e63ae242e6 runtime: split extern.go into debug.go, extern.go, sig.go.
move mal next to the other malloc functions.

R=r
CC=golang-dev
https://golang.org/cl/1701045
2010-06-21 20:53:49 -07:00
Russ Cox
121a16fa95 runtime: delete old types
R=r
CC=golang-dev
https://golang.org/cl/1715043
2010-06-21 18:03:25 -07:00
Russ Cox
45bdf0367e reflect: add Kind, remove Int8Type, Int8Value, etc.
update other code to match.

R=r
CC=golang-dev
https://golang.org/cl/1680044
2010-06-20 12:16:25 -07:00
Russ Cox
21ff75bc0e complex divide: match C99 implementation
R=iant, ken2, r, r2, ken3
CC=golang-dev
https://golang.org/cl/1686044
2010-06-18 15:46:00 -07:00
Russ Cox
c9172fb2a3 runtime: correct fault for 16-bit divide on Leopard
R=r
CC=golang-dev
https://golang.org/cl/1703041
2010-06-14 18:07:17 -07:00
Russ Cox
53a529ab2b runtime: fix 386 signal handler bug
Cannot assume that g == m->curg at time of signal.
Must save actual g and restore.

Fixes flaky crashes with messages like

throw: malloc mlookup
throw: malloc/free - deadlock
throw: unwindstack on self
throw: free mlookup

(and probably others) when running cgo.

R=iant
CC=golang-dev
https://golang.org/cl/1648043
2010-06-12 10:48:04 -07:00
Alex Brainman
c1e20720f7 runtime: switch to OS stack during Windows syscall
R=rsc
CC=golang-dev
https://golang.org/cl/1381041
2010-06-11 01:38:12 -07:00
Alex Brainman
fdb460ec11 runtime: free lock handles on Windows
R=rsc
CC=golang-dev
https://golang.org/cl/1652041
2010-06-11 00:53:54 -07:00
Russ Cox
565b5dc076 gc: new typechecking rules
* Code for assignment, conversions now mirrors spec.
* Changed some snprint -> smprint.
* Renamed runtime functions to separate
  interface conversions from type assertions:
  convT2I, assertI2T, etc.
* Correct checking of \U sequences.

Fixes #840.
Fixes #830.
Fixes #778.

R=ken2
CC=golang-dev
https://golang.org/cl/1303042
2010-06-08 18:50:02 -07:00
Daniel Theophanes
129c6c14d1 runtime: finish pchw -> tiny, added gettime for tiny
R=rsc
CC=golang-dev
https://golang.org/cl/1514041
2010-06-07 14:18:42 -07:00
Evan Shaw
69879f0414 runtime: Fix printing -Inf
R=rsc
CC=golang-dev
https://golang.org/cl/1258044
2010-06-01 14:08:15 -07:00
Alex Brainman
d5a8647d80 syscall: windows SysAlloc should use stdcall_raw not syscall
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/1382041
2010-05-28 11:47:09 -07:00
Russ Cox
21518ea2af runtime: free old hashmap pieces during resizing
R=r
CC=golang-dev
https://golang.org/cl/1254044
2010-05-24 14:31:10 -07:00
Russ Cox
f58ba18a08 runtime: correct tracebacks for nascent goroutines, even closures
Fixes #780.

R=r
CC=golang-dev
https://golang.org/cl/1221042
2010-05-21 14:40:21 -07:00
Russ Cox
4843b130bb runtime: avoid allocation for fixed strings
R=r
CC=golang-dev
https://golang.org/cl/1083041
2010-05-19 21:33:31 -07:00
Russ Cox
b198c8612e runtime: allow large map values
Fixes #772.

R=ken2
CC=golang-dev
https://golang.org/cl/1206043
2010-05-19 12:57:47 -07:00
Ian Lance Taylor
e1b47159ab Save the scheduling state even predawn.
This permits cgo callbacks to work when run in init code.
Otherwise cgocallback switches to the wrong stack address.

R=rsc
CC=golang-dev
https://golang.org/cl/1123043
2010-05-06 22:07:03 -07:00
Rob Pike
eb48bfbbda runtime.GOMAXPROCS: hack it to have it return the old value.
R=rsc
CC=golang-dev
https://golang.org/cl/1140041
2010-05-06 11:50:47 -07:00
Russ Cox
7d7ebd2fe1 runtime, strconv: tiny cleanups
R=r
CC=golang-dev
https://golang.org/cl/1081042
2010-05-03 17:47:40 -07:00
Russ Cox
23c0aa3916 runtime/arm: fix build
Import _mulv from Inferno again, change R9 to R2.
Not sure what the other differences were for, but
they weren't working.

TBR=kaib
CC=golang-dev
https://golang.org/cl/1079041
2010-05-03 13:24:39 -07:00
Giles Lean
3c32300c4d runtime: update godefs usage comment for GOARCH=386 GOOS={darwin,freebsd}
When trying to regenerate src/pkg/runtime/darwin/386/defs.h
on a 64 bit capable Snow Leopard (OS X 10.6.3) system I
needed to add -f -m32 to godefs, as this OS and hardware
combination defaults to 64 bit compilation.

For safety, make the same change to the 32 bit FreeBSD
instructions in .../freebsd/defs.c.  (Tested OK and no
problems introduced.)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/1052042
2010-05-03 01:26:39 -07:00
Russ Cox
6361f52fc4 gc: be pickier about slice, chan, array, and map sizes
Fixes #589.

R=ken2
CC=golang-dev
https://golang.org/cl/1032044
2010-05-01 13:15:42 -07:00
Alex Brainman
f81d471940 rename GOOS=mingw to GOOS=windows
R=rsc, Joe Poirier
CC=golang-dev
https://golang.org/cl/1015043
2010-04-29 23:45:14 -07:00
Russ Cox
718da3339a darwin: bsdthread_create can fail; print good error
Fixes #549.

R=adg
CC=golang-dev
https://golang.org/cl/1019042
2010-04-28 19:36:42 -07:00
Russ Cox
000ab98df6 5l, 6l, 8l, runtime: make -s binaries work
5l, 6l, 8l: change ELF header so that strip doesn't destroy binary

Fixes #261.

R=iant, r
CC=golang-dev
https://golang.org/cl/994044
2010-04-27 22:40:26 -07:00
Russ Cox
c6138efbcb runtime: closures, defer bug fix for Native Client
Enable package tests for Native Client build.

R=r
CC=golang-dev
https://golang.org/cl/957042
2010-04-22 17:52:22 -07:00
Russ Cox
214a55b06a runtime: switch state back to Grunning after recovery
Fixes #733.

R=r
CC=golang-dev
https://golang.org/cl/958041
2010-04-21 16:27:41 -07:00
Russ Cox
20c50cf0f8 runtime: rename cgo2c, *.cgo to goc2c, *.goc
to avoid confusion with real cgo

R=r
CC=golang-dev
https://golang.org/cl/904046
2010-04-20 17:03:25 -07:00
Kai Backman
26e846429d support for printing floats:
fmt.Printf("float32 %f\n", float32(1234.56789))
fmt.Printf("float64 %f\n", float64(1234.56789))
->
float32 1234.567871
float64 1234.567890

this is a snapshot. extended instruction support, corner cases
and fixes coming in subseuent cls.

R=rsc
CC=dpx, golang-dev
https://golang.org/cl/876045
2010-04-15 12:43:49 +03:00
Russ Cox
c3e54f0988 runtime: better trace for fault due to nil pointer call
R=r
CC=golang-dev
https://golang.org/cl/854048
2010-04-13 22:31:47 -07:00
Russ Cox
6363542695 runtime: delete malx, skip_depth argument to malloc
remove internal functions from traces in gopprof instead.

R=r
CC=golang-dev
https://golang.org/cl/855046
2010-04-09 15:30:40 -07:00
Ian Lance Taylor
a4f8d36ba5 Run initcgo for all amd64 targets, not just GNU/Linux.
This is required to make cgo export work on Darwin.  Note that
this corrects the stack alignment when calling initcgo to that
required by gcc on amd64.

R=rsc
CC=golang-dev
https://golang.org/cl/907041
2010-04-09 14:15:15 -07:00
Ian Lance Taylor
2e20386fc7 Library support for cgo export.
These functions are used to call from a C function back to a
Go function.  This only includes 386 support.

R=rsc
CC=golang-dev
https://golang.org/cl/834045
2010-04-09 13:30:35 -07:00
Ian Lance Taylor
2d0ff3f1a6 Support cgo export on amd64.
R=rsc
CC=golang-dev
https://golang.org/cl/857045
2010-04-09 13:30:11 -07:00
Russ Cox
c60d048594 runtime: fix build (panic) for FreeBSD
R=adg
CC=golang-dev
https://golang.org/cl/867046
2010-04-08 21:13:42 -07:00
Russ Cox
5963dbac08 runtime: turn divide by zero, nil dereference into panics
tested on linux/amd64, linux/386, linux/arm, darwin/amd64, darwin/386.
freebsd untested; will finish in a separate CL.

for now all the panics are errorStrings.
richer structures can be added as necessary
once the mechanism is shaked out.

R=r
CC=golang-dev
https://golang.org/cl/906041
2010-04-08 18:15:30 -07:00
Russ Cox
72157c300b runtime: fix bad status throw
when garbage collector sees recovering goroutine

Fixes #711.

R=r
CC=golang-dev
https://golang.org/cl/869045
2010-04-08 13:24:53 -07:00
Russ Cox
2f0cae46d8 runtime: work around kernel bug in Snow Leopard signal handling
Could not take a signal on threads other than the main thread.
If you look at the spinning binary with dtrace, you can see a
fault happening over and over:

    $ dtrace -n '
    fbt::user_trap:entry /execname=="boot32" && self->count < 10/
    {
        self->count++;
        printf("%s %x %x %x %x", probefunc, arg1, arg2, arg3, arg4);
        stack();
        tracemem(arg4, 256);
    }'

    dtrace: description 'fbt::user_trap:entry ' matched 1 probe
    CPU     ID                    FUNCTION:NAME
      1  17015                  user_trap:entry user_trap 0 10 79af0a0 79af0a0
                  mach_kernel`lo_alltraps+0x12a

             0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f  0123456789abcdef
         0: 0e 00 00 00 37 00 00 00 00 00 00 00 1f 00 00 00  ....7...........
        10: 1f 00 00 00 a8 33 00 00 00 00 00 01 00 00 00 00  .....3..........
        20: 98 ba dc fe 07 09 00 00 00 00 00 00 98 ba dc fe  ................
        30: 06 00 00 00 0d 00 00 00 34 00 00 00 9e 1c 00 00  ........4.......
        40: 17 00 00 00 00 02 00 00 ac 30 00 00 1f 00 00 00  .........0......
        50: 00 00 00 00 00 00 00 00 0d 00 00 00 e0 e6 29 00  ..............).
        60: 34 00 00 00 00 00 00 00 9e 1c 00 00 00 00 00 00  4...............
        70: 17 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00  ................
        80: ac 30 00 00 00 00 00 00 1f 00 00 00 00 00 00 00  .0..............
        90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        a0: 48 00 00 00 10 00 00 00 85 00 00 00 a0 f2 29 00  H.............).
        b0: 69 01 00 02 00 00 00 00 e6 93 04 82 ff 7f 00 00  i...............
        c0: 2f 00 00 00 00 00 00 00 06 02 00 00 00 00 00 00  /...............
        d0: 78 ee 42 01 01 00 00 00 1f 00 00 00 00 00 00 00  x.B.............
        e0: 00 ed 9a 07 00 00 00 00 00 00 00 00 00 00 00 00  ................
        f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................

    ...

The memory dump shows a 32-bit exception frame:

    x86_saved_state32

    gs = 0x37
    fs = 0
    es = 0x1f
    ds = 0x1f
    edi = 0x33a8
    esi = 0x01000000
    ebp = 0
    cr2 = 0xfedcba98
    ebx = 0x0907
    edx = 0
    ecx = 0xfedcba98
    eax = 0x06
    trapno = 0x0d
    err = 0x34
    eip = 0x1c9e
    cs = 0x17
    efl = 0x0200
    uesp = 0x30ac
    ss = 0x1f

The cr2 of 0xfedcba98 is the address that the new thread read
to cause the fault, but note that the trap is now a GP fault with
error code 0x34, meaning it's moved past the cr2 problem and on
to an invaild segment selector.  The 0x34 is suspiciously similar
to the 0x37 in gs, and sure enough, OS X forces gs to have
that value in the signal handler, and if your thread hasn't set
up that segment (known as USER_CTHREAD), you'll fault on the IRET
into the signal handler and never be able to handle a signal.

The kernel bug is that it forces segment 0x37 without making sure
it is a valid segment.  Leopard also forced 0x37 but had the courtesy
to set it up first.

Since OS X requires us to set up that segment (using the
thread_fast_set_cthread_self system call), we might as well
use it instead of the more complicated i386_set_ldt call to
set up our per-OS thread storage.

Also add some more zeros to bsdthread_register for new arguments
in Snow Leopard (apparently unnecessary, but being careful).

Fixes #510.

R=r
CC=golang-dev
https://golang.org/cl/824046
2010-04-08 13:24:37 -07:00
Russ Cox
24c58174b2 runtime: use explicit flag when finalizer goroutine is waiting
Avoids spurious wakeups during other sleeping by that goroutine.
Fixes #711.

R=r
CC=golang-dev
https://golang.org/cl/902041
2010-04-07 20:38:02 -07:00
Ken Thompson
b57afc2f83 another try at clearing
channel recv data.

R=rsc
CC=golang-dev
https://golang.org/cl/896041
2010-04-06 17:33:43 -07:00
Ken Thompson
dec248c665 change channel read to clear
data just read from the channel.
this will make it easier to
recognize when to garbage
collect and finalize.

R=rsc
CC=golang-dev
https://golang.org/cl/882043
2010-04-06 16:58:52 -07:00
Russ Cox
88ce9ce40c runtime: two proc bug fixes
1. Fix bug in GOMAXPROCS when trying to cut number of procs
Race could happen on any system but was
manifesting only on Xen hosted Linux.

2. Fix recover on ARM, where FP != caller SP.

R=r
CC=golang-dev
https://golang.org/cl/880043
2010-04-06 13:48:31 -07:00
Russ Cox
6d69fd1fe3 runtime: fix Caller
log: add test of Caller

New regexp in log test is picky and will require some
maintenance, but it catches off-by-one mistakes too.

Fixes #710.

R=gri
CC=esko.luontola, golang-dev
https://golang.org/cl/887043
2010-04-05 23:36:37 -07:00
Russ Cox
d89b357f76 runtime: handle malloc > 2GB correctly
R=ken2
CC=golang-dev
https://golang.org/cl/821048
2010-04-05 17:26:59 -07:00
Russ Cox
6c196015e0 runtime: various arm fixes
* correct symbol table size
  * do not reorder functions in output
  * traceback
  * signal handling
  * use same code for go + defer
  * handle leaf functions in symbol table

R=kaib, dpx
CC=golang-dev
https://golang.org/cl/884041
2010-04-05 12:51:09 -07:00
Russ Cox
f75d0d224f runtime: turn run time errors checks into panics
R=ken2, r
CC=golang-dev
https://golang.org/cl/871042
2010-04-01 22:31:27 -07:00
Russ Cox
ec53627ed5 runtime: correct memory leak in select
* adds pass 3 to dequeue from channels eagerly

various other cleanup/churn:
  * use switch on cas->send in each pass to
    factor out common code.
  * longer goto labels, commented at target
  * be more agressive about can't happen:
    throw instead of print + cope.
  * use "select" instead of "selectgo" in errors
  * use printf for debug prints when possible

R=ken2, ken3
CC=golang-dev, r
https://golang.org/cl/875041
2010-04-01 11:56:18 -07:00