• Didier Spezia's avatar
    text/template: fix race condition on function maps · ebe733cb
    Didier Spezia authored
    The Template objects are supposed to be goroutine-safe once they
    have been parsed. This includes the text and html ones.
    
    For html/template, the escape mechanism is triggered at execution
    time. It may alter the internal structures of the template, so
    a mutex protects them against concurrent accesses.
    
    The text/template package is free of any synchronization primitive.
    
    A race condition may occur when nested templates are escaped:
    the escape algorithm alters the function maps of the associated
    text templates, while a concurrent template execution may access
    the function maps in read mode.
    
    The less invasive fix I have found is to introduce a RWMutex in
    text/template to protect the function maps. This is unfortunate
    but it should be effective.
    
    Fixes #9945
    
    Change-Id: I1edb73c0ed0f1fcddd2f1516230b548b92ab1269
    Reviewed-on: https://go-review.googlesource.com/10101Reviewed-by: 's avatarRob Pike <r@golang.org>
    ebe733cb
Name
Last commit
Last update
api Loading commit data...
doc Loading commit data...
lib/time Loading commit data...
misc Loading commit data...
src Loading commit data...
test Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING.md Loading commit data...
CONTRIBUTORS Loading commit data...
LICENSE Loading commit data...
PATENTS Loading commit data...
README.md Loading commit data...
favicon.ico Loading commit data...
robots.txt Loading commit data...