Skip to content
Snippets Groups Projects
  1. Oct 28, 2022
    • Vladimir Davydov's avatar
      txn: account started, committed, and rolled back transactions · 70969d1d
      Vladimir Davydov authored
      This commit fixes BEGIN, COMMIT, and ROLLBACK counters in the box.stat()
      output. Before this commit, they always showed 0. Now, they report
      the number of started, committed, and rolled back transactions,
      respectively.
      
      Closes #7583
      
      NO_DOC=bug fix
      70969d1d
    • Ilya Verbin's avatar
      box: panic if snapshot has no system spaces during recovery · e0a9aed4
      Ilya Verbin authored
      Currently, if a snapshot contains some correct entries, but doesn't
      include system spaces, Tarantool crashes with segmentation fault, or
      for Debug build: void diag_raise(): Assertion `e != NULL' failed.
      This happens because memtx_engine_recover_snapshot returns -1, while
      diag is not set. Let's panic instead of a crash.
      
      Closes #7800
      
      NO_DOC=bugfix
      e0a9aed4
  2. Oct 27, 2022
  3. Oct 26, 2022
    • Vladimir Davydov's avatar
      msgpack: fix crash on decode of 0xc1 · ced405af
      Vladimir Davydov authored
      0xc1 isn't a valid MsgPack header, but it was allowed by mp_check.
      As a result, msgpack.decode crashed while trying to decode it.
      This commit updates the msgpuck library to fix this issue.
      
      Closes #7818
      
      NO_DOC=bug fix
      ced405af
  4. Oct 25, 2022
    • Nikolay Shirokovskiy's avatar
      box: expose box.info() before box.cfg() · ad420846
      Nikolay Shirokovskiy authored
      So one can easily check current box status.
      
      NO_DOC=minor change
      
      Closes #7255
      ad420846
    • Vladimir Davydov's avatar
      say: don't check cord for NULL · 916904b8
      Vladimir Davydov authored
      cord() can't be NULL anymore - it's created on demand if not created
      explicitly with cord_create().
      
      Follow-up #7814
      
      NO_DOC=code cleanup
      NO_TEST=code cleanup
      NO_CHANGELOG=code cleanup
      916904b8
    • Vladimir Davydov's avatar
      fiber: initialize thread-local cord on demand · 508138b7
      Vladimir Davydov authored
      We're planning to introduce a basic C API for user read views (EE-only).
      Like all other box C API functions, the new API functions will use the
      existing box error C API for reporting errors. The problem is that
      a read view created using C API should be usable from user threads
      (started with the pthread lib) while the box error C API doesn't work
      in user threads, because those threads don't have the cord pointer
      initialized (a diagnostic area is stored in a cord object).
      
      To address this issue, let's create a new cord object automatically on
      first use of cord() if it wasn't created explicitly. Automatically
      created object is destroyed at thread exit (to achieve that, we use
      the C++ RAII concept).
      
      Closes #7814
      
      NO_DOC=The C API documentation doesn't say anything about threads.
             Let's keep it this way for now. We're planning to introduce
             a new C API to work with threads in C modules. We'll update
             the doc when it's ready.
      508138b7
    • Serge Petrenko's avatar
      security: make os.getenv safe · dd7d46af
      Serge Petrenko authored
      Closes #7797
      
      NO_DOC=security fix
      NO_TEST=security fix
      dd7d46af
    • Serge Petrenko's avatar
      security: check size boundaries for getenv() returns · b86395ff
      Serge Petrenko authored
      getenv() return values cannot be trusted, because an attacker might set
      them. For instance, we shouldn't expect, that getenv() returns a value
      of some sane size.
      
      Another problem is that getenv() returns a pointer to one of
      `char **environ` members, which might change upon next setenv().
      
      Introduce a wrapper, getenv_safe(), which returns the value only when
      it fits in a buffer of a specified size, and copies the value onto the
      buffer. Use this wrapper everywhere in our code.
      
      Below's a slightly decorated output of `grep -rwn getenv ./src --include
      *.c --include *.h --include *.cc --include *.cpp --include *.hpp
      --exclude *.lua.c` as of 2022-10-14.
      `-` marks invalid occurences (comments, for example),
      `*` marks the places that are already guarded before this patch,
      `X` mars the places guarded in this patch, and
      `^` marks places fixed in the next commit:
      
      NO_WRAP
      ```
      * ./src/lib/core/coio_file.c:509:	const char *tmpdir = getenv("TMPDIR");
      X ./src/lib/core/errinj.c:75: const char *env_value = getenv(inj->name);
      - ./src/proc_title.c:202: * that might try to hang onto a getenv() result.)
      - ./src/proc_title.c:241:	* is mandatory to flush internal libc caches on getenv/setenv
      X ./src/systemd.c:54: sd_unix_path = getenv("NOTIFY_SOCKET");
      * ./src/box/module_cache.c:300: const char *tmpdir = getenv("TMPDIR");
      X ./src/box/sql/os_unix.c:1441: azDirs[0] = getenv("SQL_TMPDIR");
      X ./src/box/sql/os_unix.c:1446: azDirs[1] = getenv("TMPDIR");
      * ./src/box/lua/console.c:394: const char *envvar = getenv("TT_CONSOLE_HIDE_SHOW_PROMPT");
      ^ ./src/box/lua/console.lua:771: local home_dir = os.getenv('HOME')
      ^ ./src/box/lua/load_cfg.lua:1007: local raw_value = os.getenv(env_var_name)
      X ./src/lua/init.c:575: const char *path = getenv(envname);
      X ./src/lua/init.c:592: const char *home = getenv("HOME");
      * ./src/find_path.c:77: snprintf(buf, sizeof(buf) - 1, "%s", getenv("_"));
      ```
      NO_WRAP
      
      Part-of #7797
      
      NO_DOC=security
      b86395ff
  5. Oct 24, 2022
    • Mergen Imeev's avatar
      sql: fix another cursor invalidation · 5a38c5c9
      Mergen Imeev authored
      This patch fixes the issue described in issue #5310 when the tuple
      format has more fields than the space format. This solution is more
      general than the solution in 89057a21.
      
      Follow-up #5310
      Closes #4666
      
      NO_DOC=bugfix
      5a38c5c9
  6. Oct 21, 2022
    • Georgiy Lebedev's avatar
      build: use relative paths in diagnostics and debugging information · 256da010
      Georgiy Lebedev authored
      Since our diagnostics use the `__FILE__` macro, they provide absolute
      paths, which is kind of redundant and inconsistent: replace them with
      relative ones.
      
      As for debugging information, replacing absolute paths with relative ones
      also requires an extra command to tell the debugger where to find the
      source files, which is not convenient for developers: provide a new
      `DEV_BUILD` option (turned off by default), which replaces absolute paths
      with relative ones in debugging information if turned off.
      
      Strip the prefix map flags from compiler flags exported to tarantool via
      `src/trvia/config.h`.
      
      Closes #7808
      
      NO_DOC=<verbosity>
      NO_TEST=<verbosity>
      256da010
    • Georgiy Lebedev's avatar
      test-run: bump new version · e554e481
      Georgiy Lebedev authored
      Fixes bug with determination of debug build (tarantool/test-run#352).
      
      NO_CHANGELOG=<internal submodule version update>
      NO_TEST=<submodule version update>
      NO_DOC=<submodule version update>
      e554e481
    • Georgiy Lebedev's avatar
      build: refactor setting hardening compiler flags · dd51a2fa
      Georgiy Lebedev authored
      Setting hardening compiler flags is used in three places: default build,
      static build and enterprise build — refactor it into a separate module.
      
      Follow-up e6abe1c9
      
      NO_CHANGELOG=refactoring
      NO_DOC=refactoring
      NO_TEST=refactoring
      dd51a2fa
    • Georgiy Lebedev's avatar
      build: refactor passing compiler flags to dependencies · c6794757
      Georgiy Lebedev authored
      e6abe1c9 passes compiler flags to dependencies via a `<project>_build` macro
      parameter, which is, firstly, inconvenient, and, secondly, as a result, not
      all dependencies got the required compiler flags passed: use global
      variables instead and pass these flags to skipped dependencies.
      
      Follow-up e6abe1c9
      
      NO_CHANGELOG=refactoring
      NO_DOC=refactoring
      NO_TEST=refactoring
      c6794757
    • Georgiy Lebedev's avatar
      build: fix unsetting of variables in `add_compile_flags` macro · 4aa9f154
      Georgiy Lebedev authored
      `add_compile_flags` macro relied on undefined behaviour: instead of
      unsetting the `_lang` and `_flag` variables, it tried to unset their
      values — fix this.
      
      NO_CHANGELOG=build
      NO_DOC=build
      NO_TEST=build
      4aa9f154
  7. Oct 20, 2022
  8. Oct 19, 2022
    • Sergey Bronnokov's avatar
      ci: enable code coverage job in default ci · 66e388e8
      Sergey Bronnokov authored
      Information about test code coverage is useful on code review.
      This patch enables code coverage job in default ci.
      
      NO_CHANGELOG=not a user-visible change
      NO_DOC=not a user-visible change
      NO_TEST=ci
      66e388e8
    • Vladimir Davydov's avatar
      index: make index_read_view_iterator fixed size · 1aae12ac
      Vladimir Davydov authored
      This is a straightforward patch that makes the read view iterator struct
      fixed-size so that it can be allocated on stack. This is a pre-requisite
      for the raw C API for read views: the function that creates an iterator
      should allocate no memory.
      
      Closes #7813
      
      NO_DOC=refactoring
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      1aae12ac
    • Timur Safin's avatar
      debugger: prevent running from Tarantool REPL · ace88542
      Timur Safin authored
      At the moment we are not yet compatible with readline
      support inside of Tarantool console. Diagnose that situation
      at the moment debugger started and bail out.
      
      NO_TEST=interactive
      NO_DOC=Markdown updated
      ace88542
    • Timur Safin's avatar
      debugger: console debugger changelog and doc · a2ba5013
      Timur Safin authored
      NO_TEST=see it elsewhere
      
      Part of #7593
      
      @TarantoolBot document
      Title: Console debugger for Lua
      
      Console debugger luadebug.lua
      ==============================
      
      Module `luadebug.lua` is available as console debugger of Lua scripts.
      It's activated via:
      
      ```
      local debugger = require 'luadebug'
      debugger()
      ```
      
      Originally we have used 3rd-party code from slembcke/debugger.lua but
      significantly refactored since then.
      
      Currently available console shell commands are:
      ```
          c|cont|continue
          - continue execution
          d|down
          - move down the stack by one frame
          e|eval $expression
          - execute the statement
          f|finish|step_out
          - step forward until exiting the current function
          h|help|?
          - print this help message
          l|locals
          - print the function arguments, locals and upvalues
          n|next|step_over
          - step forward by one line (skipping over functions)
          p|print $expression
          - execute the expression and print the result
          q|quit
          - exit debugger
          s|st|step|step_into
          - step forward by one line (into functions)
          t|trace|bt
          - print the stack trace
          u|up
          - move up the stack by one frame
          w|where $linecount
          - print source code around the current line
      ```
      
      Console debugger `luadebug.lua` allows to see sources of builtin
      Tarantool module (e.g. `@builtin/datetime.lua`), and it uses new
      function introduced for that purpose `tarantool.debug.getsources()`,
      one could use this function in any external GUI debugger (i.e. vscode
      or JetBrains) if need to show sources of builtin modules while they
      have been debugged.
      
      > Please see third_party/lua/README-luadebug.md for a fuller description
      > of an original luadebug.lua implementation.
      a2ba5013
    • Timur Safin's avatar
      debugger: luatest for console debugger · 0a5fb86d
      Timur Safin authored
      Created luatest test for interactive debugger luadebug.lua.
      We use separate debug-target.lua for execution under
      control of debugger session.
      
      NO_DOC=test
      NO_CHANGELOG=test
      0a5fb86d
    • Timur Safin's avatar
      debugger: correct step_over for unbalanced calls/returns · a8a47a30
      Timur Safin authored
      Number of 'call' hook invocations is always greater than
      number of 'return' hook events. (i.e. ffi functions does use
      `call` but there is no `return`. Same is for builtin functions
      like `assert` or `error`).
      
      We count number of stack frames available, and stop once
      level is once again less or equal to the necessary one.
      Math.huge is used to stop on each line (trace mode).
      
      NO_CHANGELOG=internal
      NO_DOC=internal
      NO_TEST=internal
      a8a47a30
    • Timur Safin's avatar
      debugger: use NO_COLOR to disable coloring · 1163aa05
      Timur Safin authored
      Do not use non-standard DBG_NOCOLOR, but use NO_COLOR [^1]
      for disabling color output on terminals.
      
      [^1]: https://no-color.org/
      
      NO_DOC=later
      NO_CHANGELOG=internal
      NO_TEST=internal
      1163aa05
    • Timur Safin's avatar
      debugger: refactor proper initialization · f7a5336c
      Timur Safin authored
      Show debugger header only when repl is called.
      
      NO_TEST=bugfix
      NO_DOC=bugfix
      NO_CHANGELOG=bugfix
      f7a5336c
    • Timur Safin's avatar
      debugger: refactor commands helper · f5a9331e
      Timur Safin authored
      Create command matcher and help map using convenient
      builder function.
      
      Commands described in a form:
      ```
          {'f.inish|step_out', 'step out', cmd_finish},
          {'p.rint $expression', 'execute the expression', cmd_print},
      ```
      where we could introduce multiple aliases, commands with arguments,
      commands descriptions and function handlers.
      
      NO_DOC=internal
      NO_CHANGELOG=internal
      NO_TEST=internal
      f5a9331e
    • Timur Safin's avatar
      debugger: refactor luadebug.lua · f7d90f84
      Timur Safin authored
      - refactor setmetatable usage to be more idiomatic;
      - get rid of hardcode of `luadebug.lua` and use DEBUGGER
        instead. It will be necessary later for controlling
        of a name displayed by shell;
      - refactor colored output facilities.
      
      NO_TEST=refactoring
      NO_DOC=refactoring
      NO_CHANGELOG=refactoring
      f7d90f84
    • Timur Safin's avatar
      debugger: cleanup code · e52e283a
      Timur Safin authored
      Get rid of all irrelevant for the Tarantool code:
      - branches of code for non-LuaJIT interpreter;
      - LuaJIT, but Windows-specific code;
      - luadebug.lua (former debugger.lua) readline functions
        were incompatible with Tarantool console readline,
        so disable it entirely;
      - Also fixed multiple luacheck warnings.
      
      NO_DOC=refactoring
      NO_CHANGELOG=refactoring
      NO_TEST=refactoring
      e52e283a
    • Timur Safin's avatar
      debugger: retrieve @builtin/%s.lua sources · e608a737
      Timur Safin authored
      Extend Tarantool kernel internal API with the call
      `tarantool.debug.getsources()` to allow to retrieve sources
      of a Tarantool `builtin/*` modules to show them in the
      debugger shell.
      
      Created simple luatest script for checking consistency
      of a values returned from `require 'tarantool'.debug.getsources()`
      and an ctual script file content we expected to receive.
      
      NO_DOC=see future commit
      NO_CHANGELOG=see future commit
      e608a737
    • Timur Safin's avatar
      debugger: enable autolisting · 03cb944f
      Timur Safin authored
      Enable automatical visualization of current context
      after every next debugger step - so called "autolisting".
      
      This supposedly resemble lldb behaviour, which is simplifying
      debugging in CHUI.
      
      NO_DOC=internal
      NO_CHANGELOG=internal
      NO_TEST=internal
      03cb944f
    • Timur Safin's avatar
      refactor: format luadebug.lua · a04b43c8
      Timur Safin authored
      Attempt to better format style of the imported
      luadebug.lua (formerly known as debugger.lua)
      
      NO_DOC=refactoring
      NO_CHANGELOG=rafactoring
      NO_TEST=refactoring
      a04b43c8
    • Timur Safin's avatar
      debugger: added luadebug.lua · 3d8086f0
      Timur Safin authored
      Use 3rd-party module https://github.com/slembcke/debugger.lua
      as a basis for our debugger CLI shell, rename it to
      luadebug.lua to avoid collision with vscode and JetBrains
      debugger helper scripts.
      
      NO_DOC=yet
      NO_CHANGELOG=yet
      NO_TEST=yet
      3d8086f0
    • Mergen Imeev's avatar
      box: fix format of _vfunc · 707da125
      Mergen Imeev authored
      The _vfunc system space is the sysview for the _func system space.
      However, the _vfunc format is different from the _func format. This
      patch makes the _vfunc format the same as the _func format.
      
      Closes #7822
      
      NO_DOC=bugfix
      707da125
  9. Oct 18, 2022
    • Georgiy Lebedev's avatar
      uri: optimize allocation of parameters and their values dynamic arrays · 5cad0759
      Georgiy Lebedev authored
      Allocation of URI parameters and their values dynamic arrays is done
      inefficiently: they are reallocated each time a new parameter or parameter
      value is added — grow them exponentially instead.
      
      `struct uri_param` and `struct uri` are exposed in Lua via FFI
      (see src/lua/uri.lua): add warnings about the necessity of reflecting
      changes to them in `ffi.cdecl`.
      
      Closes #7155
      
      NO_DOC=optimization
      NO_TEST=optimization
      5cad0759
    • Timur Safin's avatar
      datetime: datetimes subtractions ignored timezone · 0daed8d5
      Timur Safin authored
      We used to ignore timezone difference (in `tzoffset`) for
      datetime subtraction operation:
      
      ```
      tarantool> datetime.new{tz='MSK'} - datetime.new{tz='UTC'}
      ---
      - +0 seconds
      ...
      
      tarantool> datetime.new{tz='MSK'}.timestamp -
                 datetime.new{tz='UTC'}.timestamp
      ---
      - -10800
      ...
      ```
      
      Now we accumulate tzoffset difference in the minute component
      of a resultant interval:
      
      ```
      tarantool> datetime.new{tz='MSK'} - datetime.new{tz='UTC'}
      ---
      - -180 minutes
      ...
      ```
      
      Closes #7698
      
      NO_DOC=bugfix
      0daed8d5
    • Timur Safin's avatar
      datetime: fix interval arithmetic for DST · 6ca07285
      Timur Safin authored
      We did not take into consideration the fact that
      as result of date/time arithmetic we could get
      in a different timezone, if DST boundary has been
      crossed during operation.
      
      ```
      tarantool> datetime.new{year=2008, month=1, day=1,
      			tz='Europe/Moscow'} +
      	   datetime.interval.new{month=6}
      ---
      - 2008-07-01T01:00:00 Europe/Moscow
      ...
      ```
      
      Now we resolve tzoffset at the end of operation if
      tzindex is not 0.
      
      Fixes #7700
      
      NO_DOC=bugfix
      6ca07285
    • Yaroslav Lobankov's avatar
      ci: use `coveralls-lcov` instead of GitHub action · 761574e3
      Yaroslav Lobankov authored
      In PR #7791 the coverage stuff is slightly updated. The changes are
      related to excluding some directories where the coverage will not be
      calculated. The patch itself is straightforward enough, but I can see
      the problems with uploading the results to coveralls.io:
      
      NO_WRAP
          Using lcov file: ./coverage.info
          FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
      
          <--- Last few GCs --->
      
          [2683200:0x327c000]    27836 ms: Scavenge 2033.4 (2038.7) -> 2033.2 (2044.2) MB, 6.8 / 0.0 ms  (average mu = 0.258, current mu = 0.243) allocation failure
          [2683200:0x327c000]    27854 ms: Scavenge 2036.7 (2044.2) -> 2037.1 (2044.4) MB, 15.6 / 0.0 ms  (average mu = 0.258, current mu = 0.243) allocation failure
          [2683200:0x327c000]    27871 ms: Scavenge 2037.2 (2044.4) -> 2036.7 (2055.9) MB, 17.1 / 0.0 ms  (average mu = 0.258, current mu = 0.243) allocation failure
      
          <--- JS stacktrace --->
      
          ==== JS stack trace =========================================
      
              0: ExitFrame [pc: 0x140dc19]
          Security context: 0x2481918808d1 <JSObject>
              1: encode(aka encode) [0x23ec5e514a11] [/opt/actions-runner/_work/_actions/coverallsapp/github-action/v1.1.2/node_modules/qs/lib/utils.js:~118] [pc=0x193ecd3d5d82](this=0x35d34e4804b1 <undefined>,0x1e5895380119 <Very long string[60387428]>)
              2: stringify(aka stringify) [0x23ec5e5174c9] [/opt/actions-runner/_work/_actions/coverallsapp/github-action/v1.1.2/n...
      
           1: 0xa1a640 node::Abort() [/opt/actions-runner/externals/node12/bin/node]
           2: 0xa1aa4c node::OnFatalError(char const*, char const*) [/opt/actions-runner/externals/node12/bin/node]
           3: 0xb9a62e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/opt/actions-runner/externals/node12/bin/node]
           4: 0xb9a9a9 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/opt/actions-runner/externals/node12/bin/node]
           5: 0xd57c25  [/opt/actions-runner/externals/node12/bin/node]
           6: 0xd582b6 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [/opt/actions-runner/externals/node12/bin/node]
           7: 0xd64b75 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/opt/actions-runner/externals/node12/bin/node]
           8: 0xd65a25 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/opt/actions-runner/externals/node12/bin/node]
           9: 0xd670cf v8::internal::Heap::HandleGCRequest() [/opt/actions-runner/externals/node12/bin/node]
          10: 0xd15b35 v8::internal::StackGuard::HandleInterrupts() [/opt/actions-runner/externals/node12/bin/node]
          11: 0x1071176 v8::internal::Runtime_StackGuard(int, unsigned long*, v8::internal::Isolate*) [/opt/actions-runner/externals/node12/bin/node]
          12: 0x140dc19  [/opt/actions-runner/externals/node12/bin/node]
      NO_WRAP
      
      I have tried to use the latest version of the action (1.1.3), but I have
      got the same issue.
      
      It looks like it is a `coverallsapp/github-action` issue due to issue
      in JavaScript due to inefficient amount of memory. The corresponding
      bug [1] was filed against the repo.
      
      So I suggest switching to the console utility `coveralls-lcov`. I did
      some internal testing and it works fine.
      
      [1] https://github.com/coverallsapp/github-action/issues/133
      
      Fixes tarantool/tarantool-qa#278
      
      NO_DOC=ci
      NO_TEST=ci
      NO_CHANGELOG=ci
      761574e3
Loading