Skip to content

Commit

Permalink
fix: read_span_flatbuffer was leaking an example per invocation
Browse files Browse the repository at this point in the history
Parser logic needs to use VW::finish_example() rather than simple deletion to get rid of examples because the incoming example_factory may be grabbing examples from the example pool.
  • Loading branch information
lokitoth committed Feb 13, 2024
1 parent ca77f15 commit 28d8b05
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion vowpalwabbit/fb_parser/src/parse_example_flatbuffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "vw/core/error_constants.h"
#include "vw/core/global_data.h"
#include "vw/core/parser.h"
#include "vw/core/vw.h"

#include <cfloat>
#include <fstream>
Expand Down Expand Up @@ -112,7 +113,7 @@ bool read_span_flatbuffer(
}
} while (has_more);

delete temp_ex[0];
VW::finish_example(*all, temp_ex);
return true;
}

Expand Down
2 changes: 2 additions & 0 deletions vowpalwabbit/fb_parser/tests/read_span_tests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ void create_flatbuffer_span_and_validate(VW::workspace& w, const T& prototype)
VW::parsers::flatbuffer::read_span_flatbuffer(&w, buffer, size, ex_fac, parsed_examples);

verify_multi_ex(w, prototype, parsed_examples);

VW::finish_example(w, parsed_examples);
}

TEST(FlatbufferParser, ReadSpanFlatbuffer_SingleExample)
Expand Down

0 comments on commit 28d8b05

Please sign in to comment.