-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speedup string serialization #87
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61baa98
to
7f2d9b0
Compare
INFO: found LLVMFuzzerCustomMutator (0x55ad8bcfd380). Disabling -len_control by default.
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 2310284358
INFO: Loaded 1 modules (21726 inline 8-bit counters): 21726 [0x55ad8c102eb0, 0x55ad8c10838e),
INFO: Loaded 1 PC tables (21726 PCs): 21726 [0x55ad8c108390,0x55ad8c15d170),
INFO: 9008 files found in ./corpus/luaL_loadbuffer_proto
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 79204 bytes
INFO: seed corpus: files: 9008 min: 1b max: 79204b total: 198290211b rss: 52Mb
<snipped>
[libprotobuf WARNING google/protobuf/text_format.cc:324] Warning parsing text-format lua_grammar.Block: 3:10: Message type "lua_grammar.Statement" has no field named "stat".
[libprotobuf ERROR google/protobuf/text_format.cc:309] Error parsing text-format lua_grammar.Block: 21:20: Expected "{", found "}".
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_M_construct null not valid
==872877== ERROR: libFuzzer: deadly signal
#0 0x55ad8bcc5c31 in __sanitizer_print_stack_trace (/home/sergeyb/sources/lua-c-api-tests/build/luajit/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test+0x1dfc31) (BuildId: 538e5dd9f5da96f50d45a4f7e485e80bbd43971f)
#1 0x55ad8bc1b0c8 in fuzzer::PrintStackTrace() (/home/sergeyb/sources/lua-c-api-tests/build/luajit/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test+0x1350c8) (BuildId: 538e5dd9f5da96f50d45a4f7e485e80bbd43971f)
#2 0x55ad8bc00943 in fuzzer::Fuzzer::CrashCallback() (/home/sergeyb/sources/lua-c-api-tests/build/luajit/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test+0x11a943) (BuildId: 538e5dd9f5da96f50d45a4f7e485e80bbd43971f)
#3 0x7f762fa4251f (/lib/x86_64-linux-gnu/libc.so.6+0x4251f) (BuildId: 490fef8403240c91833978d494d39e537409b92e)
#4 0x7f762fa969fb in __pthread_kill_implementation nptl/pthread_kill.c:43:17
#5 0x7f762fa969fb in __pthread_kill_internal nptl/pthread_kill.c:78:10
#6 0x7f762fa969fb in pthread_kill nptl/pthread_kill.c:89:10
#7 0x7f762fa42475 in gsignal signal/../sysdeps/posix/raise.c:26:13
#8 0x7f762fa287f2 in abort stdlib/abort.c:79:7
#9 0x7f76302a2b9d (/lib/x86_64-linux-gnu/libstdc++.so.6+0xa2b9d) (BuildId: e37fe1a879783838de78cbc8c80621fa685d58a2)
#10 0x7f76302ae20b (/lib/x86_64-linux-gnu/libstdc++.so.6+0xae20b) (BuildId: e37fe1a879783838de78cbc8c80621fa685d58a2)
#11 0x7f76302ae276 in std::terminate() (/lib/x86_64-linux-gnu/libstdc++.so.6+0xae276) (BuildId: e37fe1a879783838de78cbc8c80621fa685d58a2)
#12 0x7f76302ae4d7 in __cxa_throw (/lib/x86_64-linux-gnu/libstdc++.so.6+0xae4d7) (BuildId: e37fe1a879783838de78cbc8c80621fa685d58a2)
#13 0x7f76302a5343 in std::__throw_logic_error(char const*) (/lib/x86_64-linux-gnu/libstdc++.so.6+0xa5343) (BuildId: e37fe1a879783838de78cbc8c80621fa685d58a2)
#14 0x55ad8bbeb0fc in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>::basic_string<std::allocator<char>>(char const*, std::allocator<char> const&) (/home/sergeyb/sources/lua-c-api-tests/build/luajit/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test+0x1050fc) (BuildId: 538e5dd9f5da96f50d45a4f7e485e80bbd43971f)
#15 0x55ad8bcfe2e0 in report_error(lua_State*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) /home/sergeyb/sources/lua-c-api-tests/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test.cc:204:24
#16 0x55ad8bcfdd08 in TestOneProtoInput(lua_grammar::Block const&) /home/sergeyb/sources/lua-c-api-tests/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test.cc:386:3
#17 0x55ad8bcfd738 in LLVMFuzzerTestOneInput /home/sergeyb/sources/lua-c-api-tests/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test.cc:330:1
#18 0x55ad8bc01fd6 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/sergeyb/sources/lua-c-api-tests/build/luajit/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test+0x11bfd6) (BuildId: 538e5dd9f5da96f50d45a4f7e485e80bbd43971f)
#19 0x55ad8bc01685 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) (/home/sergeyb/sources/lua-c-api-tests/build/luajit/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test+0x11b685) (BuildId: 538e5dd9f5da96f50d45a4f7e485e80bbd43971f)
#20 0x55ad8bc033f2 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/home/sergeyb/sources/lua-c-api-tests/build/luajit/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test+0x11d3f2) (BuildId: 538e5dd9f5da96f50d45a4f7e485e80bbd43971f)
#21 0x55ad8bc0390c in fuzzer::Fuzzer::Loop(std::vector<fuzzer::SizedFile, std::allocator<fuzzer::SizedFile>>&) (/home/sergeyb/sources/lua-c-api-tests/build/luajit/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test+0x11d90c) (BuildId: 538e5dd9f5da96f50d45a4f7e485e80bbd43971f)
#22 0x55ad8bbf1005 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/sergeyb/sources/lua-c-api-tests/build/luajit/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test+0x10b005) (BuildId: 538e5dd9f5da96f50d45a4f7e485e80bbd43971f)
#23 0x55ad8bc1ba92 in main (/home/sergeyb/sources/lua-c-api-tests/build/luajit/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test+0x135a92) (BuildId: 538e5dd9f5da96f50d45a4f7e485e80bbd43971f)
#24 0x7f762fa29d8f in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#25 0x7f762fa29e3f in __libc_start_main csu/../csu/libc-start.c:392:3
#26 0x55ad8bbe5b54 in _start (/home/sergeyb/sources/lua-c-api-tests/build/luajit/tests/capi/luaL_loadbuffer_proto/luaL_loadbuffer_proto_test+0xffb54) (BuildId: 538e5dd9f5da96f50d45a4f7e485e80bbd43971f)
NOTE: libFuzzer has rudimentary signal handlers.
Combine libFuzzer with AddressSanitizer or similar for better crash reports.
SUMMARY: libFuzzer: deadly signal
MS: 0 ; base unit: 0000000000000000000000000000000000000000
artifact_prefix='./'; Test unit written to ./crash-4dfc116321db62682fde7cff188d2cf97f51f315 |
- clamp before cleaning string because cleaning is not cheap (O(n), where max n is equal to kMaxStrLength) - call cleaning for identifiers only, there is no sense to cleaning string literals - replace symbols disallowed by Lua grammar in indentifier's names with '_' The patch saves 16 sec on 145k samples (401 sec before the patch and 385 sec after the patch). It is actually not so much, but it is about 2.5 min per hour.
7f2d9b0
to
7d37d82
Compare
it is not related to the patch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
n
is equal tokMaxStrLength
)This change saves 16 sec on 145k samples (before 401 sec and after 385 sec). It is actually not so much, but it is a 2.5 min per hour.