a8m / mark

A markdown processor written in Go. built for fun.
MIT License
203 stars 16 forks source link

Package contains data races #5

Open henhouse opened 6 years ago

henhouse commented 6 years ago

Upon running the tests with a --race flag, you'll find the package is riddled with many race conditions. Due to this, the package cannot safely be utilized in any concurrent fashion.

I will only paste a snippet example here as the actual result errors totalled in over 3000 lines. A simple invocation of the tests with go test --race should be sufficient enough to investigate.

WARNING: DATA RACE
Read at 0x00c42031d818 by goroutine 161:
  github.com/a8m/mark.(*lexer).nextItem()
      /Users/henryhenderson/go/src/github.com/a8m/mark/lexer.go:279 +0xb5
  github.com/a8m/mark.(*parse).peek()
      /Users/henryhenderson/go/src/github.com/a8m/mark/parser.go:126 +0x154
  github.com/a8m/mark.(*parse).parse()
      /Users/henryhenderson/go/src/github.com/a8m/mark/parser.go:38 +0x50
  github.com/a8m/mark.(*parse).parseBlockQuote()
      /Users/henryhenderson/go/src/github.com/a8m/mark/parser.go:280 +0x194
  github.com/a8m/mark.(*parse).parse()
      /Users/henryhenderson/go/src/github.com/a8m/mark/parser.go:59 +0x422
  github.com/a8m/mark.(*Mark).Render()
      /Users/henryhenderson/go/src/github.com/a8m/mark/mark.go:45 +0x4d
  github.com/a8m/mark.Render()
      /Users/henryhenderson/go/src/github.com/a8m/mark/mark.go:59 +0x5d
  github.com/a8m/mark.TestCommonMark()
      /Users/henryhenderson/go/src/github.com/a8m/mark/mark_test.go:1666 +0x14d
  testing.tRunner()
      /usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:777 +0x16d

Previous write at 0x00c42031d818 by goroutine 447:
  github.com/a8m/mark.(*lexer).next()
      /Users/henryhenderson/go/src/github.com/a8m/mark/lexer.go:114 +0x138
  github.com/a8m/mark.(*lexer).peek()
      /Users/henryhenderson/go/src/github.com/a8m/mark/lexer.go:262 +0x3c
  github.com/a8m/mark.lexText()
      /Users/henryhenderson/go/src/github.com/a8m/mark/lexer.go:231 +0x78
  github.com/a8m/mark.(*lexer).run()
      /Users/henryhenderson/go/src/github.com/a8m/mark/lexer.go:101 +0xa1

Goroutine 161 (running) created at:
  testing.(*T).Run()
      /usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:824 +0x564
  testing.runTests.func1()
      /usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:1063 +0xa4
  testing.tRunner()
      /usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:777 +0x16d
  testing.runTests()
      /usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:1061 +0x4e1
  testing.(*M).Run()
      /usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:978 +0x2cd
  main.main()
      _testmain.go:56 +0x22a

Goroutine 447 (running) created at:
  github.com/a8m/mark.lex()
      /Users/henryhenderson/go/src/github.com/a8m/mark/lexer.go:84 +0x112
  github.com/a8m/mark.(*parse).parseBlockQuote()
      /Users/henryhenderson/go/src/github.com/a8m/mark/parser.go:279 +0xbe
  github.com/a8m/mark.(*parse).parse()
      /Users/henryhenderson/go/src/github.com/a8m/mark/parser.go:59 +0x422
  github.com/a8m/mark.(*Mark).Render()
      /Users/henryhenderson/go/src/github.com/a8m/mark/mark.go:45 +0x4d
  github.com/a8m/mark.Render()
      /Users/henryhenderson/go/src/github.com/a8m/mark/mark.go:59 +0x5d
  github.com/a8m/mark.TestCommonMark()
      /Users/henryhenderson/go/src/github.com/a8m/mark/mark_test.go:1666 +0x14d
  testing.tRunner()
      /usr/local/Cellar/go/1.10/libexec/src/testing/testing.go:777 +0x16d
==================
a8m commented 6 years ago

Thanks for reporting this issue @henhouse! I'll try to work on that ASAP.