~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to test/fixedbugs/issue8158.go

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-11-18 15:12:26 UTC
  • mfrom: (14.2.12 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20141118151226-zug7vn93mn3dtiz3
Tags: 2:1.3.2-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - Support co-installability with gccgo-go tool:
    - d/rules,golang-go.install: Rename bin/go -> bin/golang-go
    - d/golang-go.{postinst,prerm}: Install/remove /usr/bin/go using
      alternatives.
  - d/copyright: Amendments for full compiliance with copyright format.
  - d/control: Demote golang-go.tools to Suggests to support Ubuntu MIR.
  - dropped patches (now upstream):
    - d/p/issue27650045_40001_50001.diff
    - d/p/issue28050043_60001_70001.diff
    - d/p/issue54790044_100001_110001.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// run
 
2
 
 
3
// Copyright 2014 The Go Authors.  All rights reserved.
 
4
// Use of this source code is governed by a BSD-style
 
5
// license that can be found in the LICENSE file.
 
6
 
 
7
package main
 
8
 
 
9
import (
 
10
        "runtime"
 
11
        "time"
 
12
)
 
13
 
 
14
func main() {
 
15
        c := make(chan bool, 1)
 
16
        go f1(c)
 
17
        <-c
 
18
        time.Sleep(10 * time.Millisecond)
 
19
        go f2(c)
 
20
        <-c
 
21
}
 
22
 
 
23
func f1(done chan bool) {
 
24
        defer func() {
 
25
                recover()
 
26
                done <- true
 
27
                runtime.Goexit() // left stack-allocated Panic struct on gp->panic stack
 
28
        }()
 
29
        panic("p")
 
30
}
 
31
 
 
32
func f2(done chan bool) {
 
33
        defer func() {
 
34
                recover()
 
35
                done <- true
 
36
                runtime.Goexit()
 
37
        }()
 
38
        time.Sleep(10 * time.Millisecond) // overwrote Panic struct with Timer struct
 
39
        runtime.GC()                      // walked gp->panic list, found mangled Panic struct, crashed
 
40
        panic("p")
 
41
}