FAQ
A test case I stumbled upon today:

package main

func Encode() ([]byte, error) {
t := []byte("hello world")
return t, nil
}

func main() {
var s []byte
ch := make(chan bool, 1)
go func() {
var err error
s, err = Encode()
ch <- true
_ = err
}()
str := string(s)
<-ch
_ = str
}


https://codereview.appspot.com/6525052/

Search Discussions

  • Dvyukov at Nov 1, 2012 at 7:59 pm

    On 2012/11/01 19:51:29, remyoudompheng wrote:
    A test case I stumbled upon today:
    package main
    func Encode() ([]byte, error) {
    t := []byte("hello world")
    return t, nil
    }
    func main() {
    var s []byte
    ch := make(chan bool, 1)
    go func() {
    var err error
    s, err = Encode()
    ch <- true
    _ = err
    }()
    str := string(s)
    <-ch
    _ = str
    }
    :)
    Did race detector help you?

    https://codereview.appspot.com/6525052/
  • Remyoudompheng at Nov 1, 2012 at 8:07 pm
    It sort of didn't. I wanted to write a trivial example for stack split,
    so I used "s, err = json.Marshal(blah)" since encoding/json is usually
    stack hungry.

    And was surprised to see it was not reporting anything for a concurrent
    read of s. See http://codereview.appspot.com/6821068

    https://codereview.appspot.com/6525052/
  • Dvyukov at Nov 2, 2012 at 6:39 am

    On 2012/11/01 20:07:28, remyoudompheng wrote:
    It sort of didn't. I wanted to write a trivial example for stack
    split, so I
    used "s, err = json.Marshal(blah)" since encoding/json is usually
    stack hungry.
    And was surprised to see it was not reporting anything for a
    concurrent read of
    s. See http://codereview.appspot.com/6821068
    Ah, so it's a false negative case... just figured that's because of
    OBLOCK... and then looked at your patch :)



    https://codereview.appspot.com/6525052/
  • Dvyukov at Nov 2, 2012 at 8:05 am

    On 2012/11/02 06:39:00, dvyukov wrote:
    On 2012/11/01 20:07:28, remyoudompheng wrote:
    It sort of didn't. I wanted to write a trivial example for stack
    split, so I
    used "s, err = json.Marshal(blah)" since encoding/json is usually
    stack
    hungry.
    And was surprised to see it was not reporting anything for a
    concurrent read
    of
    Ah, so it's a false negative case... just figured that's because of OBLOCK...
    and then looked at your patch :)

    Added the tests for OBLOCK:
    https://codereview.appspot.com/6525052/diff2/12019:16019/src/pkg/runtime/race/mop_test.go



    https://codereview.appspot.com/6525052/
  • Dvyukov at Nov 8, 2012 at 4:04 pm

    On 2012/10/07 18:25:45, dvyukov wrote:
    What do you think about high-level organisation?
    All test files except race_test.go are +build ignore.
    race_test.go executes 'go test -race -v all_other_test_files', and
    parses the
    output.
    For tests starting with func TestRaceXXX it expects a race to be
    detected. For
    tests starting with func TestNoRaceXXX it expects no race to be detected.
    Then prints summary along the lines of:
    NoRaceFin .
    RaceFin FAILED
    NoRaceCgoSync .
    NoRaceIOFile .
    NoRaceIOHttp .
    Passed 209 of 229 tests (91.27%, 0+, 20-).
    0+ means 0 false positives.
    20- means 20 false negatives.
    I think I need to add "expected failures" to be able to run it on
    buildbot.

    I've added the ability to mark "expected to fail" tests. Now this test
    can pass even with some not-yet-implemented race detector features. I.e.
    it does not fail go test -race std.
    PTAL

    https://codereview.appspot.com/6525052/
  • Rsc at Nov 12, 2012 at 9:49 pm
    I suggest moving the excluded files into a testdata subdirectory. The go
    command knows to ignore files in testdata directories, even *.go files.


    https://codereview.appspot.com/6525052/
  • Dvyukov at Nov 14, 2012 at 2:16 pm

    On 2012/11/12 21:49:35, rsc wrote:
    I suggest moving the excluded files into a testdata subdirectory. The
    go command
    knows to ignore files in testdata directories, even *.go files.
    Done. PTAL.

    https://codereview.appspot.com/6525052/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedNov 1, '12 at 7:51p
activeNov 14, '12 at 2:16p
posts8
users3
websitegolang.org

3 users in discussion

Dvyukov: 5 posts Remyoudompheng: 2 posts Rsc: 1 post

People

Translate

site design / logo © 2022 Grokbase