tree-sitter/test/helpers
Phil Turnbull 52cec9ed39 Rework SpyInput buffer handling
SpyInput uses a fixed-size buffer and explicitly zeros memory which is good for
catching logic errors but defeats valgrind's memory tracking. Use a separate
buffer of exactly the correct size for each request. This correctly catches the
problem under valgrind:

```
==8694== Invalid read of size 2
==8694==    at 0x54EFFB: utf16_iterate (utf16.c:10)
==8694==    by 0x551126: ts_lexer__get_lookahead (lexer.c:54)
==8694==    by 0x5515CD: ts_lexer_start (lexer.c:154)
==8694==    by 0x54699F: parser(long,...)(long long) (parser.c:297)
==8694==    by 0x54788A: parser__get_lookahead (parser.c:439)
==8694==    by 0x54B2D3: parser__advance (parser.c:1150)
==8694==    by 0x54C2AA: parser_parse (parser.c:1348)
==8694==    by 0x53F063: ts_document_parse_with_options (document.c:136)
==8694==    by 0x53EF43: ts_document_parse (document.c:107)
==8694==    by 0x4AED11: {lambda()#1}::operator()() const::{lambda()#1}::operator()() const::{lambda()#4}::operator()() const::{lambda()#4}::operator()() const (document_test.cc:82)
==8694==    by 0x4B56B6: std::_Function_handler<void (), {lambda()#1}::operator()() const::{lambda()#1}::operator()() const::{lambda()#4}::operator()() const::{lambda()#4}>::_M_invoke(std::_Any_data const&) (functional:1871)
==8694==    by 0x40F8C5: std::function<void ()>::operator()() const (functional:2267)
==8694==  Address 0x5d08be0 is 0 bytes inside a block of size 1 alloc'd
==8694==    at 0x4C2E80F: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==8694==    by 0x507C3E: SpyInput::read(void*, unsigned int*) (spy_input.cc:66)
==8694==    by 0x55103D: ts_lexer__get_chunk (lexer.c:29)
==8694==    by 0x5515B6: ts_lexer_start (lexer.c:152)
==8694==    by 0x54699F: parser(long,...)(long long) (parser.c:297)
==8694==    by 0x54788A: parser__get_lookahead (parser.c:439)
==8694==    by 0x54B2D3: parser__advance (parser.c:1150)
==8694==    by 0x54C2AA: parser_parse (parser.c:1348)
==8694==    by 0x53F063: ts_document_parse_with_options (document.c:136)
==8694==    by 0x53EF43: ts_document_parse (document.c:107)
==8694==    by 0x4AED11: {lambda()#1}::operator()() const::{lambda()#1}::operator()() const::{lambda()#4}::operator()() const::{lambda()#4}::operator()() const (document_test.cc:82)
==8694==    by 0x4B56B6: std::_Function_handler<void (), {lambda()#1}::operator()() const::{lambda()#1}::operator()() const::{lambda()#4}::operator()() const::{lambda()#4}>::_M_invoke(std::_Any_data const&) (functional:1871)
```
2017-07-18 12:16:37 -07:00
..
dedent.h Rename spec -> test 2017-03-09 20:40:01 -08:00
encoding_helpers.cc Handle invalid UTF8 in encoding test helpers 2017-04-27 14:49:44 -07:00
encoding_helpers.h Rename spec -> test 2017-03-09 20:40:01 -08:00
file_helpers.cc Rename spec -> test 2017-03-09 20:40:01 -08:00
file_helpers.h Rename spec -> test 2017-03-09 20:40:01 -08:00
load_language.cc Add a benchmark command 2017-07-05 14:14:38 -07:00
load_language.h Rename spec -> test 2017-03-09 20:40:01 -08:00
point_helpers.cc Rename spec -> test 2017-03-09 20:40:01 -08:00
point_helpers.h Rename spec -> test 2017-03-09 20:40:01 -08:00
random_helpers.cc Add a benchmark command 2017-07-05 14:14:38 -07:00
random_helpers.h Add a benchmark command 2017-07-05 14:14:38 -07:00
read_test_entries.cc Add a benchmark command 2017-07-05 14:14:38 -07:00
read_test_entries.h Add a benchmark command 2017-07-05 14:14:38 -07:00
record_alloc.cc Build benchmarks in Test mode for now 2017-07-05 17:27:50 -07:00
record_alloc.h Rename spec -> test 2017-03-09 20:40:01 -08:00
scope_sequence.cc Rename spec -> test 2017-03-09 20:40:01 -08:00
scope_sequence.h Rename spec -> test 2017-03-09 20:40:01 -08:00
spy_input.cc Rework SpyInput buffer handling 2017-07-18 12:16:37 -07:00
spy_input.h Rework SpyInput buffer handling 2017-07-18 12:16:37 -07:00
spy_logger.cc Rename spec -> test 2017-03-09 20:40:01 -08:00
spy_logger.h Rename spec -> test 2017-03-09 20:40:01 -08:00
stderr_logger.cc Rename spec -> test 2017-03-09 20:40:01 -08:00
stderr_logger.h Rename spec -> test 2017-03-09 20:40:01 -08:00
stream_methods.cc Represent LookaheadSet using vectors of bool 2017-07-12 16:02:01 -07:00
stream_methods.h Add PREC_DYNAMIC rule for resolving runtime ambiguities 2017-07-06 15:24:45 -07:00
tree_helpers.cc Support anonymous tokens inside of RENAME rules 2017-07-14 10:19:58 -07:00
tree_helpers.h Add test for an example found during fuzzing 2017-06-30 21:55:50 -07:00