go-org-orgwiki/org
Niklas Fasching 5464ab37d2 Fix race condition surrounding global orgWriter
Since writers are normally only used synchronously (i.e. to write one document
at a time), we don't guard modifications to their internal
state (e.g. temporarily replacing the string.Builder in WriteNodesAsString)
against race conditions.

The package global `orgWriter` and corresponding use cases of it (`org.String`,
`$node.String`) break that pattern - the writer is potentially used from
multiple go routines at the same time. This results in race conditions that
manifest as error messages like e.g.

    could not write output: runtime error: invalid memory address or nil pointer dereference. Using unrendered content.

Additionally, since we catch panics in `Document.Write`, the corresponding
stack trace is lost and dependents of go-org never know what hit them.

As using a writer across simultaneously across go routines is not a standard
pattern, we'll sync the use of the global `orgWriter` instead of trying to make
the actual writer threadsafe; less code noise for the common use case.
2023-03-12 11:28:55 +01:00
..
testdata update the fixtures 2023-03-02 17:56:27 +08:00
block.go Fix race condition surrounding global orgWriter 2023-03-12 11:28:55 +01:00
document.go Fix race condition surrounding global orgWriter 2023-03-12 11:28:55 +01:00
drawer.go Fix race condition surrounding global orgWriter 2023-03-12 11:28:55 +01:00
footnote.go Fix race condition surrounding global orgWriter 2023-03-12 11:28:55 +01:00
fuzz.go Fix fuzz 2019-01-02 21:22:13 +01:00
headline.go Fix race condition surrounding global orgWriter 2023-03-12 11:28:55 +01:00
html_entity.go Fix html entities: support \<entity>{} and prevent partial replacements 2022-04-28 18:09:42 +02:00
html_writer.go Fix race condition surrounding global orgWriter 2023-03-12 11:28:55 +01:00
html_writer_test.go Allow customizing header level offset 2023-02-18 15:08:18 -08:00
inline.go Fix race condition surrounding global orgWriter 2023-03-12 11:28:55 +01:00
keyword.go Fix race condition surrounding global orgWriter 2023-03-12 11:28:55 +01:00
list.go Fix race condition surrounding global orgWriter 2023-03-12 11:28:55 +01:00
org_writer.go Add support for latex blocks / environments 2022-11-02 14:16:57 +01:00
org_writer_test.go Refactor writer tests 2022-06-18 16:10:19 +02:00
paragraph.go Fix race condition surrounding global orgWriter 2023-03-12 11:28:55 +01:00
table.go Fix race condition surrounding global orgWriter 2023-03-12 11:28:55 +01:00
util.go highlight: support highlighting lines in the default writer 2022-07-18 03:56:15 +09:00
util_test.go highlight: add tests for ParseRanges 2022-07-25 19:27:11 +09:00
writer.go Add support for latex blocks / environments 2022-11-02 14:16:57 +01:00