Skip to content
Snippets Groups Projects
  1. Aug 25, 2023
  2. Aug 24, 2023
    • Sergey Bronnikov's avatar
      ci: update paths in a fuzzing workflow · a67dd3b1
      Sergey Bronnikov authored
      Fuzzing is a heavyweight job, we can reduce a set of paths used for
      triggering this job and therefore reduce an overall time of testing in
      some cases.
      
      The patch replaces `.github/workflows/**` to
      `.github/workflows/fuzzing.yml` because workflows are independent and
      changes in other workflows does not affect fuzzing at all and patch adds
      Lua files (`**.lua`) to ignores because fuzzing focused on C/C++ code.
      
      NO_CHANGELOG=ci
      NO_DOC=ci
      NO_TEST=ci
      
      (cherry picked from commit f14cb97d)
      Unverified
      a67dd3b1
  3. Aug 22, 2023
    • Sergey Bronnikov's avatar
      test/static: add a seed corpus for decimal_to_int64_fuzzer · 8e851e77
      Sergey Bronnikov authored
      NO_DOC=seed corpus
      NO_CHANGELOG=seed corpus
      NO_TEST=seed corpus
      
      (cherry picked from commit 4894863e)
      8e851e77
    • Sergey Bronnikov's avatar
      test/fuzz: add fuzzing test for decoding decimals · 67f8f70d
      Sergey Bronnikov authored
      NO_DOC=testing
      NO_CHANGELOG=testing
      
      (cherry picked from commit 4deadeb8)
      67f8f70d
    • Sergey Bronnikov's avatar
      test/static: add a seed corpus for IPROTO decoders · 0d7edaa1
      Sergey Bronnikov authored
      NO_DOC=seed corpus
      NO_CHANGELOG=seed corpus
      NO_TEST=seed corpus
      
      (cherry picked from commit 4b5fb953)
      0d7edaa1
    • Sergey Bronnikov's avatar
      test/fuzz: add fuzzing tests for IPROTO decoders · ead890a5
      Sergey Bronnikov authored
      Examples of IPROTO decoding issues: #3900, #1928, #6781.
      Patch adds a number of fuzzing tests that covers IPROTO decoding:
      
      - xrow_decode_auth
      - xrow_decode_begin
      - xrow_decode_call
      - xrow_decode_dml
      - xrow_decode_id
      - xrow_decode_raft
      - xrow_decode_sql
      - xrow_decode_watch
      - xrow_greeting_decode
      
      NO_DOC=testing
      NO_CHANGELOG=testing
      
      (cherry picked from commit 46cacf35)
      ead890a5
    • Sergey Bronnikov's avatar
      test/fuzz: collect and print Lua metrics · 00a57af1
      Sergey Bronnikov authored
      Fuzzing test for LuaJIT generates random Lua programs and executes them.
      We want to build a fuzzing test that will produce Lua programs that will
      not contain semantic errors and will trigger as much as possible
      components in LuaJIT.
      
      This proposed patch introduces metrics that gathered after running the
      test. LuaJIT metrics gathered using LuaJIT getmetrics module [1]. All
      gathered metrics test will output after running with a finite number of
      runs or finite duration of time (options `-runs` and `-max_total_time`)
      or after sending SIGUSR1 to a test process.
      
      ```
      $ ./build/test/fuzz/luaL_loadbuffer/luaL_loadbuffer_fuzzer -runs=1000
      
      <snipped>
      
      Done 1000 runs in 1 second(s)
      Total number of samples: 1000
      Total number of samples with errors: 438 (43%)
      Total number of samples with recorded traces: 87 (8%)
      Total number of samples with snap restores: 30 (3%)
      Total number of samples with abort traces: 55 (5%)
      ```
      
      1. https://www.tarantool.io/en/doc/latest/reference/tooling/luajit_getmetrics/#getmetrics-c-api
      
      NO_CHANGELOG=testing
      NO_DOC=testing
      
      (cherry picked from commit 430fa6a2)
      00a57af1
    • Rimma Tolkacheva's avatar
      test/fuzz: refactor LuaJIT fuzzer · f437e1e8
      Rimma Tolkacheva authored
      This refactoring will:
      
      1. Move macros from a header to the source file.
      Macros should be used in header only with undef to avoid redefinitions.
      Undef directive is not useful since we want to use these macros in the
      source file.
      
      2. Remove `using namespace lua_grammar` from header.
      https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rs-using-directive
      
      3. Moving serializer entry point and constant parameters into
      luajit_fuzzer namespace.
      It's a common practice in C++ to avoid name collisions.
      
      4. Move serializer functions into anonymous namespace.
      These functions are not a part of the interface so should have
      static linkage.
      https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rs-unnamed2
      
      5. Fix ConvertToStringDefault function.
      It was logically wrong so it would generate an identifier `123` from
      `*123`.
      
      NO_CHANGELOG=internal
      NO_DOC=fuzzer fix
      
      (cherry picked from commit 56488e15)
      f437e1e8
    • klauwier's avatar
      test/fuzz: fix luaJIT fuzzer timeout · f1898c3f
      klauwier authored
      LuaJIT fuzzer used to stop due to timeout caused by infinite cycles and
      recursions. Counters were introduced for every cycle and function to
      address LuaJIT fuzzer timeouts.
      
      The idea is to add unique counters for every cycle and function to
      ensure finite code execution, if it wasn't already. For while, repeat,
      for cycles, local and global named, anonymous functions, counters will
      be initialized before the code generated from protobuf, and checked
      in the first body statement. An entry point for the serializer was
      created to count cycles and functions for counter initialization.
      
      The idea was taken from a paper "Program Reconditioning: Avoiding
      Undefined Behaviour When Finding and Reducing Compiler Bugs" [1].
      
      Here is an example of a change in serialized code made by this commit.
      
      Before:
      ```lua
      while (true) do
          foo = 'bar'
      end
      function bar()
          bar()
      end
      ```
      
      After:
      ```lua
      counter_0 = 0
      counter_1 = 0
      while (true) do
          if counter_0 > 5 then
              break
          end
          counter_0 = counter_0 + 1
          foo = 'bar'
      end
      function bar()
          if counter_1 > 5 then
              return
          end
          counter_1 = counter_1 + 1
          bar()
      end
      ```
      Protobuf structures that reproduce the timeout problem were added to
      the LuaJIT fuzzer corpus.
      
      [1] https://www.doc.ic.ac.uk/~afd/homepages/papers/pdfs/2023/PLDI.pdf
      
      NO_CHANGELOG=internal
      NO_DOC=fuzzer fix
      
      (cherry picked from commit 4d004bbe)
      f1898c3f
    • klauwier's avatar
      test/fuzz: add breaks to switch-case · 2ac1a9cf
      klauwier authored
      Cases in two switches had no breaks, so they were falling
      through. Breaks were added to solve the problem. Code
      generated by the LuaJIT fuzzer became more various.
      
      NO_CHANGELOG=internal
      NO_DOC=fuzzer fix
      
      (cherry picked from commit 4430cac9)
      2ac1a9cf
    • Sergey Bronnikov's avatar
      test/fuzz: fix datetime_strptime fuzzing test · ba6bd045
      Sergey Bronnikov authored
      Function `datetime_strptime` decodes string with datetime according to
      specified format, it accepts a datetime struct, buffer with datetime and
      string with format in arguments. Fuzzing test used static string
      "iso8601" as a format and it blocked fuzzing test to cover functions
      used by datetime_strptime under the hood. Fuzz introspector shows that
      code coveraged by a test is quite low.
      
      Patch updates the test to make it more effective: buffer with datetime
      and format string are generated using FDP (Fuzzing Data Provider).
      
      Test file extension was changed to .cc, because FuzzingDataProvider is
      used and we need building it by C++ compiler.
      
      Function `tnt_strptime` uses assert, that triggered by fuzzing tests.
      Therefore it was replaced with to if..then.
      
      1. https://storage.googleapis.com/oss-fuzz-introspector/tarantool/
      
      Fixes #8490
      
      NO_CHANGELOG=fuzzing test
      NO_DOC=fuzzing test
      NO_TEST=fuzzing test
      
      (cherry picked from commit a1bd6e0b)
      ba6bd045
    • Timur Safin's avatar
      datetime: fix buffer overflow in tnt_strptime · 996a2874
      Timur Safin authored
      Fixes #8502
      Needed for #8490
      
      NO_DOC=bugfix
      NO_TEST=covered by fuzzing test
      
      (cherry picked from commit 783a7040)
      996a2874
    • Sergey Bronnikov's avatar
      test: add initial corpus with Lua samples · 95133c03
      Sergey Bronnikov authored
      Corpus based on PUC Rio Lua tests imported from LuaJIT repository [1].
      
      1. https://github.com/tarantool/luajit/tree/tarantool/test/PUC-Rio-Lua-5.1-tests
      
      Follows up #4823
      
      NO_CHANGELOG=corpus
      NO_DOC=corpus
      NO_TEST=corpus
      
      (cherry picked from commit 890eb224)
      95133c03
    • Dmitriy Nesterov's avatar
      test/fuzz: add grammar-based LuaJIT fuzzer · cadf5ab6
      Dmitriy Nesterov authored
      Patch adds a LuaJIT fuzzer based on libprotobuf-mutator and LibFuzzer.
      Grammar is described via messages in protobuf format, serializer is
      applied to convert .proto format to string.
      
      For displaying generated code on the screen during fuzzing set
      the environment variable 'LPM_DUMP_NATIVE_INPUT'.
      
      For displaying error messages from lua functions set
      the environment variable 'LUA_FUZZER_VERBOSE'.
      
      Note: UndefinedBehaviourSanitizer is unsupported by LuaJIT (see #8473),
      so fuzzing test is disabled when CMake option ENABLE_UB_SANITIZER is
      passed.
      
      Closes #4823
      
      NO_DOC=<fuzzing testing of LuaJIT>
      NO_TEST=<fuzzing testing of LuaJIT>
      
      (cherry picked from commit a287c853)
      cadf5ab6
    • Sergey Bronnikov's avatar
      cmake: propagate CMAKE_BUILD_TYPE for ProtobufMutator · 1ef71919
      Sergey Bronnikov authored
      Follows-up #4823
      
      NO_CHANGELOG=internal
      NO_DOC=internal
      NO_TEST=internal
      
      (cherry picked from commit 95d62cfc)
      1ef71919
    • Dmitriy Nesterov's avatar
      cmake: add dependencies for LuaJIT and SQL fuzzers · 3785264a
      Dmitriy Nesterov authored
      Added Google's 'libprotobuf-mutator' and 'protobuf' libraries
      for developing grammar-based LuaJIT and SQL fuzzers based on
      LibFuzzer.
      
      It is needed to build protobuf module from source because
      by default, the system-installed version of protobuf is used
      by libprotobuf-mutator, and this version can be too old.
      
      Part of #4823
      
      NO_CHANGELOG=<dependencies>
      NO_DOC=<dependencies>
      NO_TEST=<dependencies>
      
      (cherry picked from commit b11072a6)
      3785264a
    • Dmitriy Nesterov's avatar
      test/fuzz: add options for better fuzzing · d2140a7c
      Dmitriy Nesterov authored
      Added options for fuzzing and for getting more information
      on debugging.
      
      NO_CHANGELOG=<fuzzing options>
      NO_DOC=<fuzzing options>
      NO_TEST=<fuzzing options>
      
      (cherry picked from commit 69f21e25)
      d2140a7c
    • Sergey Bronnikov's avatar
      test/fuzz: add a function for generating fuzz test targets · 18a4f2c5
      Sergey Bronnikov authored
      Commit 2be74a65 ("test/cmake: add a function for generating unit
      test targets") added a function for generating unit test targets in
      CMake. This function makes code simpler and less error-prone.
      
      Proposed patch adds a similar function for generating fuzzing test
      targets in CMake.
      
      NO_CHANGELOG=build infrastructure updated
      NO_DOC=build infrastructure updated
      NO_TEST=build infrastructure updated
      
      (cherry picked from commit d9643bfd)
      18a4f2c5
  4. Aug 21, 2023
    • Ilya Verbin's avatar
      test: fix fiber stack overflow test not overflowing · dcf345fe
      Ilya Verbin authored
      test/unit/guard.cc calls stack_break_f() recursively until the stack
      overflows and a signal is fired, however it relies on undefined behavior
      when compares pointers to local variables. Fixed by comparing
      __builtin_frame_address() instead.
      
      One of the examples of this UB is when ASAN allocates local variables on
      fake stacks, in that case the test completes without the stack overflow.
      
      Also this patch disables ASAN for stack_break_f() to keep the array on the
      fiber stack (see the corresponding comment) and marks it as volatile to
      avoid optimizing it away by the compiler.
      
      Closes tarantool/tarantool-qa#323
      
      NO_DOC=test fix
      NO_CHANGELOG=test fix
      
      (cherry picked from commit 05b696c7)
      dcf345fe
  5. Aug 17, 2023
    • Magomed Kostoev's avatar
      box: fix invalid memory access in tuple_compare_with_key_sequential · 06ff582b
      Magomed Kostoev authored
      Since number type was introduced we can not assume if tuples are
      equal by comparison then their sizes are equal too. So the place
      the assumption is used is fixed.
      
      Closes #8899
      
      NO_DOC=bugfix
      
      (cherry picked from commit f4de9faf)
      06ff582b
    • Magomed Kostoev's avatar
      tuple_compare: introduce key_compare_and_skip_parts · 09393447
      Magomed Kostoev authored
      This commit introduces the key_compare_and_skip_parts function
      that advances the keys on equal parts. These changes has been
      extracted from commit ca832f27
      ("tuple_compare: compare not only functional key with key").
      
      NO_CHANGELOG=internal
      NO_DOC=internal
      NO_TEST=see the next commit
      09393447
    • Vladimir Davydov's avatar
      lua: fix heap-use-after-free bug in tuple format constructor · 46b33a7a
      Vladimir Davydov authored
      Runtime tuple formats are reusable, which means that a tuple format
      returned by runtime_tuple_format_new may not be brand new, but actually
      be used by a Lua object. As a result, if we call any function that may
      trigger Lua GC between runtime_tuple_format_new and tuple_format_ref,
      the tuple format may be deleted, leading to a use-after-free bug. This
      is what happens in lbox_tuple_format_new. Fix this issue by taking a
      reference to the format before pushing a cdata object to the Lua stack
      in lbox_push_tuple_format.
      
      The issue was fixed in the master branch by commit 28ec245d ("lua:
      fix heap-use-after-free bug in tuple format constructor"). This isn't
      a clean cherry-pick because the code changed quite a bit.
      
      Closes #8889
      
      NO_DOC=bug fix
      NO_TEST=difficult to reproduce, found by ASAN
      
      (cherry picked from commit 4123061b)
      46b33a7a
  6. Aug 16, 2023
    • Igor Munkin's avatar
      luajit: bump new version · 1fe54450
      Igor Munkin authored
      * ci: support coveralls
      * cmake: add code coverage support
      * test: run flake8 static analysis via CMake
      * test: fix E741 errors by pycodestyle
      * test: fix E722 errors by pycodestyle
      * test: fix E711 errors by pycodestyle
      * test: fix E502 errors by pycodestyle
      * test: fix E501 errors by pycodestyle
      * test: fix E305 errors by pycodestyle
      * test: fix E303 errors by pycodestyle
      * test: fix E302 errors by pycodestyle
      * test: fix E301 errors by pycodestyle
      * test: fix E275 errors by pycodestyle
      * test: fix E251 errors by pycodestyle
      * test: fix E231 errors by pycodestyle
      * test: fix E203 errors by pycodestyle
      * test: fix E201 and E202 errors by pycodestyle
      * test: suppress E131 errors by pycodestyle
      * test: fix E128 errors by pycodestyle
      * test: fix E122 errors by pycodestyle
      * gdb: fix Python <assert> statement usage
      
      NO_DOC=LuaJIT submodule bump
      NO_TEST=LuaJIT submodule bump
      NO_CHANGELOG=LuaJIT submodule bump
      1fe54450
  7. Aug 15, 2023
    • Ilya Verbin's avatar
      core: fix ASAN_START_SWITCH_FIBER() usage · f22c3d40
      Ilya Verbin authored
      The `__sanitizer_start_switch_fiber()` function takes a pointer as the
      first argument to store the current fake stack if there is one (it is
      necessary when stack-use-after-return detection is enabled). When leaving a
      fiber definitely, NULL must be passed so that the fake stack is destroyed.
      
      Before this patch, NULL was passed for dead fibers, however this is wrong
      for dead fibers that are recycled and resumed. In such cases ASAN destroys
      the fake stack, and the fiber crashes trying to use it in `fiber_yield()`
      upon return from `coro_transfer()`.
      
      Closes tarantool/tarantool-qa#321
      
      NO_DOC=bugfix
      NO_TEST=tested by test-release-asan workflow
      
      (cherry picked from commit 72a6abee)
      f22c3d40
  8. Aug 14, 2023
    • Ilya Grishnov's avatar
      box: fix shared lang between connected clients · bf1f05b0
      Ilya Grishnov authored
      Fixed the implementation of the box console.
      Before this fix, result of `\set language` is shared between clients
      via `console.connect`, despite the fact that clients have different
      `box.session.id`. Now the parameter of the selected language is stored
      by each client in his own `box.session.storage`.
      
      Fixes #8817
      
      NO_DOC=bugfix
      
      (cherry picked from commit e4fda4b7)
      bf1f05b0
    • Gleb Kashkin's avatar
      test: add prompt setter to interactive helper · 66443f84
      Gleb Kashkin authored
      Interactive console test helper could be used for remote connection too,
      for that purpose prompt needs to be changed accordingly to connection
      type.
      
      This patch introduces getter and setter for the prompt. Prompt is
      configured per session, so it is advised to create a new session
      for each test case (e.g. with before_each()).
      
      NO_CHANGELOG=test helper change
      NO_DOC=test helper change
      
      (cherry picked from commit ed86a729)
      66443f84
    • Yaroslav Lobankov's avatar
      test: mv interactive_tarantool.lua to ./test/ dir · 20cdf1ca
      Yaroslav Lobankov authored
      The ./test/luatest_helpers/interactive_tarantool.lua module is not
      a luatest helper. So moving it to the ./test/ dir and removing empty
      ./test/luatest_helpers/.
      
      NO_DOC=testing stuff
      NO_TEST=testing stuff
      NO_CHANGELOG=testing stuff
      
      (cherry picked from commit 5493db7c)
      20cdf1ca
    • Alexander Turenko's avatar
      test: add a helper for testing interactive mode · ca55107f
      Alexander Turenko authored
      A basic (and pretty useless) example:
      
      ```lua
      local it = require('test.luatest_helpers.interactive_tarantool')
      
      local child = it.new()
      
      child:execute_command('6 * 7')
      local res = child:read_response()
      t.assert_equals(res, 42)
      
      child:close()
      ```
      
      The module also contains `:read_line()`, `:assert_line()` helpers for
      testing output directly: for example, when we need to catch a print()
      from a background fiber. It provides has constants related to terminal's
      control sequences.
      
      A real usage can be seen in a next commit.
      
      Part of #7169
      
      NO_DOC=no user visible changes
      NO_TEST=not applicable, it is a testing helper
      NO_CHANGELOG=no user visible changes
      
      (cherry picked from commit a9d96007)
      ca55107f
    • Gleb Kashkin's avatar
      console: remove ERRINJ_STDIN_ISATTY injection · 5dbcf2a1
      Gleb Kashkin authored
      As the underlying problem behind this injection is fixed in #7357 it can
      be removed and `-i` flag could be used as initially intended.
      
      Closes #7554
      Requires #7357
      NO_DOC=refactoring
      NO_CHANGELOG=refactoring
      
      (cherry picked from commit 16d6e9d2)
      5dbcf2a1
    • Gleb Kashkin's avatar
      console: fix -i being overruled by !isatty() · eafaf778
      Gleb Kashkin authored
      The interactive mode has been ignored when stdin was not a tty and is no
      more. Now results of another command can be handled by tarantool.
      Before the patch:
      ```
      $ echo 42 | tarantool -i
      LuajitError: stdin:1: unexpected symbol near '42'
      fatal error, exiting the event loop
      ```
      
      After the patch:
      ```
      $ echo 42 | tarantool -i
      Tarantool 2.5.0-130-ge3cf64a6c
      type 'help' for interactive help
      tarantool> 42
      ---
      - 42
      ...
      
      ```
      
      Closes #5064
      
      NO_DOC=bugfix
      
      (cherry picked from commit 9965e3fe)
      eafaf778
  9. Aug 08, 2023
    • Oleg Chaplashkin's avatar
      test: bump test-run to new version · 20dcf595
      Oleg Chaplashkin authored
      Bump test-run to new version with the following improvements:
      
      - luatest: fix detect tarantool crash at exit [1]
      - Fix bug when lua script name truncated by dot [2]
      - Raise an error and log it if test timeouts are set incorrectly [3]
      - Pin PyYAML version to 5.3.1 [4]
      - Add ability to set path to executable file [5]
      - Migrate tarantoolctl from tarantool repository [6]
      - Fix test-run crash when default server is crashed [7]
      - Disable reproduce content printing [8]
      
      [1] tarantool/test-run@be693d1
      [2] tarantool/test-run@a6405f1
      [3] tarantool/test-run@d34ecb0
      [4] tarantool/test-run@704420e
      [5] tarantool/test-run@0a70001
      [6] tarantool/test-run@ad43d8f
      [7] tarantool/test-run@b31329e
      [8] tarantool/test-run@31f0ced
      
      NO_DOC=test
      NO_TEST=test
      NO_CHANGELOG=test
      
      (cherry picked from commit f4511948)
      20dcf595
    • Yaroslav Lobankov's avatar
      ci: bump Clang version to 16 in release build LTO testing · b4241743
      Yaroslav Lobankov authored
      Run release build LTO testing inside a Docker container created from the
      `tarantool/testing:ubuntu-jammy-clang16` image with Clang 16 installed.
      
      Closes #318
      
      NO_DOC=ci
      NO_TEST=ci
      NO_CHANGELOG=ci
      
      (cherry picked from commit 9d0cb54f)
      b4241743
    • Yaroslav Lobankov's avatar
      ci: bump Clang version to 16 in release build testing · 0230073c
      Yaroslav Lobankov authored
      Run release build testing inside a Docker container created from the
      `tarantool/testing:ubuntu-jammy-clang16` image with Clang 16 installed.
      
      Closes #317
      
      NO_DOC=ci
      NO_TEST=ci
      NO_CHANGELOG=ci
      
      (cherry picked from commit 9134dabd)
      0230073c
    • Sergey Vorontsov's avatar
      build: change BACKUP_STORAGE URL for static build · b5d93d78
      Sergey Vorontsov authored
      NO_DOC=build
      NO_TEST=build
      NO_CHANGELOG=build
      
      (cherry picked from commit bb74d6c9)
      b5d93d78
    • Kirill Yukhin's avatar
      Add owners for /.test.mk and /.github · b2626c3f
      Kirill Yukhin authored
      Add code owners for CI-related script and
      for github automation directory.
      
      NO_CHANGELOG=no code changes
      NO_TEST=no code changes
      NO_DOC=no code changes
      
      (cherry picked from commit 9234763a)
      b2626c3f
Loading