Skip to content
Snippets Groups Projects
  1. Jan 16, 2024
    • Maksim Kaitmazian's avatar
      feat: add user name argument to `auth_method` api · eec2e89a
      Maksim Kaitmazian authored and Дмитрий Кольцов's avatar Дмитрий Кольцов committed
      User name is usually used as a salt for user password in order to
      avoid password repeating.
      For instance, postgres md5 authentication stores passwords as
      md5("password", "user"), so that the same passwords are represented by
      different hashes.
      
      part of picodata/picodata/sbroad!377
      
      @TarantoolBot document
      Title: Document updated `box.schema.user.password` declaration.
      
      Since auth methods can use user name for hashing, user name is
      added to argument list of `box.schema.user.password`.
      
      NO_TEST=there are no methods that use user name
      eec2e89a
    • godzie44's avatar
      fix: use-after-free in `cbus_endpoint_delete` · 4c6c25c5
      godzie44 authored and Дмитрий Кольцов's avatar Дмитрий Кольцов committed
      Calling a `TRASH` macro after calling the `free`
      function dereferences the pointer to the already
      freed memory.
      
      NO_DOC=picodata internal patch
      NO_CHANGELOG=picodata internal patch
      NO_TEST=picodata internal patch
      4c6c25c5
    • Denis Smirnov's avatar
      feat: expose tuple hash calculation method · bb5d5b7e
      Denis Smirnov authored and Дмитрий Кольцов's avatar Дмитрий Кольцов committed
      Picodata supports cluster-wide SQL and needs some predictable
      method to calculate tuple hashes for the bucket ids. Method
      should be available for Lua, C and Rust users. It was decided
      to expose a murmur3 hash calculation method of the key_def module.
      
      NO_DOC=picodata internal patch
      NO_CHANGELOG=picodata internal patch
      bb5d5b7e
    • godzie44's avatar
      cbus: introduce lcpipe - light cpipe · 28fe188b
      godzie44 authored and Дмитрий Кольцов's avatar Дмитрий Кольцов committed
      Introduced a new type of cbus pipe - lcpipe. The current pipe in the
      cbus - cpipe, has a number of limitations, first of all - the cpipe
      cannot be used from the 3rd party threads, cpipe only works as a channel
      between two cords. That why lcpipe is needed. Its main responsibility -
      create channel between any thread and tarantool cord.
      
      Internally lcpipe is a cpipe, but:
      - on flush triggers removed, cause triggers use thread-local mem-pool,
      this is not possible on a third party thread
      - producer event loop removed, cause there is no libev event loop in
      third party thread
      
      Also, lcpipe interface is exported to the outside world.
      
      NO_DOC=core feature
      28fe188b
    • Дмитрий Кольцов's avatar
      build(CMakeLists.txt): disable feedback daemon by default · 2c4b4e80
      Дмитрий Кольцов authored
      NO_DOC=disable feedback
      NO_TEST=disable feedback
      2c4b4e80
    • Дмитрий Кольцов's avatar
      fix(schema version): fix some types that were not updated to 64 bit · f0680680
      Дмитрий Кольцов authored
      NO_DOC=core feature
      NO_TEST=no Lua API
      NO_CHANGELOG=bugfix
      f0680680
    • Дмитрий Кольцов's avatar
      feat(json): add option to encode decimals as string · 440fc11e
      Дмитрий Кольцов authored
      Due to inconsistency of Tarantool type casting while using strict
      data types as "double" or "unsigned" it is needed
      to use "number" data type in a whole bunch of cases.
      However "number" may contain "decimal" that will be serialized into
      string by JSON builtin module.
      
      This commit adds "encode_decimal_as_number" parameter to json.cfg{}.
      That forces to encode `decimal` as JSON number to force type
      consistency in JSON output.
      Use with catious - most of JSON parsers assume that number is restricted
      to float64.
      
      NO_DOC=we do not host doc
      440fc11e
    • Denis Smirnov's avatar
      sql: recompile expired prepared statements · a38965d6
      Denis Smirnov authored and Дмитрий Кольцов's avatar Дмитрий Кольцов committed
      Actually there is no reason to throw an error and make a user
      manually recreate prepared statement when it expires. A much more
      user friendly way is to recreate it under hood when statement's
      schema version differs from the box one.
      
      NO_DOC=refactoring
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      a38965d6
    • Denis Smirnov's avatar
      fix: default result parameter type · eeeb497b
      Denis Smirnov authored and Дмитрий Кольцов's avatar Дмитрий Кольцов committed
      Problem description.
      
      When we prepare a statement with parameters in the result columns
      (for example box.prepare('select ?')) Tarantool has no information
      about the type of the output column and set it to default boolean.
      Then, on the execution phase, the type would be recalculated during
      the parameter binding.
      
      Tarantool expects that there is no way for parameter to appear in the
      result tuple other than exactly be mentioned in the final projection.
      But it is incorrect - we can easily propagate parameter from the inner
      part of the join. For example
      
      box.prepare([[select COLUMN_1 from t1 join (values (?)) as t2 on true]])
      
      In this case column COLUMN_1 in the final projection is not a
      parameter, but a "reference" to it and its type depends on the
      parameter from the inner part of the join. But as Tarantool
      recalculates only binded parameters in the result projection,
      it doesn't change the default boolean metadata type of the COLUMN_1
      and the query fails on comparison with the actual type of the tuple.
      
      Solution.
      As we don't want to patch Vdbe to make COLUMN_1 refer inner parameter,
      it was decided to make a simple workaround: change the default
      column type from BOOLEAN to ANY for parameters. It fixes the
      comparison with the actual tuple type (we do not fail), but in some
      cases get ANY column in the results where we would like to have
      explicitly defined type. Also NULL parameters would also have ANY
      type, though Tarantool prefers to have BOOLEAN in this case.
      
      Closes https://github.com/tarantool/tarantool/issues/7283
      
      NO_DOC=bug fix
      eeeb497b
    • godzie44's avatar
      sql: add sql_execute_prepared_ext function, same as sql_execute_prepared but... · 90ff6574
      godzie44 authored and Дмитрий Кольцов's avatar Дмитрий Кольцов committed
      sql: add sql_execute_prepared_ext function, same as sql_execute_prepared but without `region` parameter
      closes #2
      
      NO_DOC=minor
      NO_TEST=minor
      90ff6574
    • godzie44's avatar
      compatibility with tarantool-module: · d8c626d5
      godzie44 authored and Дмитрий Кольцов's avatar Дмитрий Кольцов committed
      - add box_tuple_data_offset function (return offset of the messagePack encoded data from the beginning of the tuple)
      - add more export functions
      
      closes #1
      
      NO_DOC=build
      NO_TEST=build
      d8c626d5
  2. Dec 07, 2023
    • Nikolay Shirokovskiy's avatar
      iproto: don't account message twice in case of override fallback · 4d379127
      Nikolay Shirokovskiy authored
      We need to call `tx_accept_msg` in `tx_process_override` before we pass
      message to the override handler. Unfortunately if handler response with
      IPROTO_HANDLER_FALLBACK we call the builtin handler for message that
      calls `tx_accept_msg` again which is not expected. Some actions of
      this function are idempotent and some are not.
      
      Let's make the function NOP if it called once again.
      
      Closes #9345
      
      NO_DOC=bugfix
      
      (cherry picked from commit 21112b06)
      4d379127
  3. Dec 05, 2023
    • Sergey Kaplun's avatar
      lua: prevent serialization of error for ucdata · 074fe0bf
      Sergey Kaplun authored
      Without checking the return value of lua_pcall()` in
      `lua_field_inspect_ucdata()`, the error message itself is returned as a
      serialized result. The result status of `lua_pcall()` is not ignored
      now.
      
      NO_DOC=bugfix
      
      Closes #9396
      
      (cherry picked from commit 98474f70)
      074fe0bf
    • Maxim Kokryashkin's avatar
      build: purge sysprof.collapse module · 2e9d205b
      Maxim Kokryashkin authored
      This module became unused as a result of LuaJIT bump made in the
      commit 88333d13 ("luajit: bump new version"), so it can be
      purged safely from the Tarantool sources.
      
      Part of #8700
      
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=added within the aforementioned commit
      
      (cherry picked from commit e2851883)
      2e9d205b
  4. Dec 02, 2023
    • Serge Petrenko's avatar
      replication: fix extraneous split-brain alerting · 718aeb14
      Serge Petrenko authored
      Current split-brain detector implementation raises an error each time a
      CONFIRM or ROLLBACK entry is received from the previous synchronous
      transaction queue owner. It is assumed that the new queue owner must
      have witnessed all the previous CONFIRMS. Besides, according to Raft,
      ROLLBACK should never happen.
      
      Actually there is a case when a CONFIRM from an old term is legal: it's
      possible that during leader transition old leader writes a CONFIRM for
      the same transaction that is confirmed by the new leader's PROMOTE. If
      PROMOTE and CONFIRM lsns match there is nothing bad about such
      situation.
      
      Symmetrically, when an old leader issues a ROLLBACK with the lsn right
      after the new leader's PROMOTE lsn, it is not a split-brain.
      
      Allow such cases by tracking the last confirmed lsn for each synchronous
      transaction queue owner and silently nopifying CONFIRMs with an lsn less
      than the one recorded and ROLLBACKs with lsn greater than that.
      
      Closes #9138
      
      NO_DOC=bugfix
      
      (cherry picked from commit ffa6ac15)
      718aeb14
    • Serge Petrenko's avatar
      replication: persist confirmed vclock on replicas · bcbe9232
      Serge Petrenko authored
      Previously the replicas only persisted the confirmed lsn of the current
      synchronous transaction queue owner. As soon as the onwer changed, the
      info about which lsn was confirmed by the previous owner was lost.
      
      Actually, this info is needed to correctly filter synchro requests
      coming from the old term, so start tracking confirmed vclock instead of
      the confirmed lsn on replicas.
      
      In-scope of #9138
      
      NO_TEST=covered by the next commit
      NO_CHANGELOG=internal change
      
      @TarantoolBot document
      Title: Document new IPROTO_RAFT_PROMOTE request field
      
      IPROTO_RAFT_PROMOTE and IPROTO_RAFT_DEMOTE requests receive a new key
      value pair:
      
      IPROTO_VCLOCK : MP_MAP
      
      The vclock holds a confirmed vclock of the node sending the request.
      
      (cherry picked from commit c4415d44)
      bcbe9232
    • Serge Petrenko's avatar
      xrow: remove SYNCHRO_BODY_LEN_MAX constant · 8d457af4
      Serge Petrenko authored
      Synchronous requests will receive a new field encoding a full vclock
      soon. Theoretically a vclock may take up to ~ 300-400 bytes (3 bytes for
      a map header + 32 components each taking up 1 byte for replica id and up
      to 9 bytes for lsn). So it makes no sense to increase
      SYNCHRO_BODY_LEN_MAX from 32 to 400-500. It would become almost the same
      as plain BODY_LEN_MAX. Simply reuse the latter everywhere.
      
      In-scope-of #9138
      
      NO_DOC=refactoring
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      
      (cherry picked from commit 53605779)
      8d457af4
    • Serge Petrenko's avatar
      xrow: fix xrow_decode_synchro rejecting non-int types · 77853bef
      Serge Petrenko authored
      There was an error in xrow_decode_synchro: it compared the expected type
      of the value to the type of the key (MP_UINT) instead of the type of the
      actual value. This went unnoticed because all values in synchro requests
      were integers.
      
      This is going to change soon, when PROMOTE requests will start holding a
      vclock, so fix the wrong type check.
      
      In-scope-of #9138
      
      NO_DOC=bugfix
      NO_CHANGELOG=not user-visible
      
      (cherry picked from commit c18410f5)
      77853bef
  5. Nov 28, 2023
    • Vladimir Davydov's avatar
      net.box: allow calling stored Lua and C module functions with self.call · d462c77c
      Vladimir Davydov authored
      The fix is simple: look up the function in `box.func` by name and, if
      found, execute its `call` method. The only tricky part is to avoid the
      lookup before `box.cfg` is called because `box.func` is unavailable at
      the time. We achieve that by checking `box.ctl.is_recovery_finished`.
      
      Closes #9131
      
      NO_DOC=bug fix
      
      (cherry picked from commit e92a8e7b)
      d462c77c
    • Nikolay Shirokovskiy's avatar
      fiber: fix use-after-free on shutdown with lingering fiber join · 18e0f810
      Nikolay Shirokovskiy authored
      On Tarantool shutdown we destroy all the fibers in some sequence. We
      don't require that all the fibers are finished before shutdown. So it
      may turn out that we first destroy some alive fiber and then destroy
      another alive fiber which joins the first one. Currently we have
      use-after-free issue in this case because clearing `link` field of
      the second fiber changes `wake` field of the first fiber.
      
      Close #9406
      
      NO_DOC=bugfix
      
      (cherry picked from commit 2f7ec948)
      18e0f810
    • Nikolay Shirokovskiy's avatar
      main: don't break graceful shutdown on init script exit · cd303945
      Nikolay Shirokovskiy authored
      Graceful shutdown is done in a special fiber which is started for
      example on SIGTERM. So it can run concurrently with fiber executing
      Tarantool init script. On init fiber exit we break event loop to pass
      control back to the Tarantool initialization code. But we fail to run
      event loop a bit more to finish graceful shutdown.
      
      The test is a bit contrived. A more real world case is when Tarantool is
      termintated during lingering box.cfg().
      
      Close #9411
      
      NO_DOC=bugfix
      
      (cherry picked from commit 786eb2ac)
      cd303945
  6. Nov 27, 2023
    • Mergen Imeev's avatar
      sql: remove one row limit in EXISTS subquery · b5b37629
      Mergen Imeev authored
      According to ANSI, EXISTS is a predicate that tests a given subquery and
      returns true if it returns more than 0 rows, false otherwise. However,
      after 2a720d11, EXISTS worked correctly only if there were exactly 0
      or 1 rows, and in all other cases it gave an error. This patch makes
      EXITS work properly.
      
      Closes #8676
      
      NO_DOC=bugfix
      
      (cherry picked from commit a5e498d1)
      b5b37629
  7. Nov 10, 2023
    • Vladimir Davydov's avatar
      cmake: check static build dependencies in post build command · adbcedc0
      Vladimir Davydov authored
      Instead of using ctest, let's simply run the CheckDependencies.cmake as
      a post build command if Tarantool was built without dependencies. The
      good thing about it is that the check will run even if the static build
      is created directly, without the /static-build/CMakeLists.txt wrapper.
      
      Part of #9242
      
      NO_DOC=build
      NO_TEST=build
      NO_CHANGELOG=build
      
      (cherry picked from commit fa4939bd)
      adbcedc0
    • Vladimir Davydov's avatar
      cmake: allow to include extra dependencies · c1327f2a
      Vladimir Davydov authored
      Tarantool EE needs to build or find some extra libraries. Let's add
      the new variable EXTRA_DEPENDENCIES_CMAKE for that. It'll be defined
      by the parent project.
      
      Since we might need to link the extra dependencies to the core library,
      we also add the new list variable EXTRA_CORE_DEPENDENCIES. If set, its
      contents will be appended to the core library dependencies list.
      
      Follow-up #9242
      
      NO_DOC=build
      NO_TEST=build
      NO_CHANGELOG=build
      
      (cherry picked from commit a367265b)
      c1327f2a
    • Vladimir Davydov's avatar
      cmake: allow to bundle static dependencies in main project · f3b31aee
      Vladimir Davydov authored
      The BUILD_STATIC cmake config option forces the build system link
      Tarantool binary statically with its dependencies. It expects that all
      static libraries on which Tarantool binary depends are available at
      build time.
      
      We don't use this option directly to create static binaries because it
      would produce different results on different build systems. Instead, we
      use the separate cmake config located in the static-build directory,
      which fetches all Tarantool dependencies from a predefined location
      before building a static binary.
      
      Having a separate cmake config is inconvenient. Let's enable bundling of
      static binary dependencies right in the main project cmake config, like
      we bundle, for example, libcurl. To achieve that, the new build option
      was introduced BUILD_STATIC_WITH_BUNDLED_LIBS. It implies BUILD_STATIC
      and also fetches and builds all required dependencies, like the
      static-build cmake config used to. The latter doesn't do it anymore;
      from now on, it just sets BUILD_STATIC_WITH_BUNDLED_LIBS when building
      Tarantool. We can't remove the static-build cmake config yet because
      there are quire a few CI workflows depending on it.
      
      Note that, just like BUILD_STATIC, BUILD_STATIC_WITH_BUNDLED_LIBS
      doesn't imply OPENSSL_USE_STATIC_LIBS so the latter should be set
      explicitly if one wants to use the static openssl library. However,
      setting OPENSSL_USE_STATIC_LIBS with BUILD_STATIC_WITH_BUNDLED_LIBS will
      force the build system use bundled static openssl library.
      
      This patch is relatively straightforward. It just moves the external
      projects from /static-build/cmake/AddDependencyProjects.cmake to /cmake
      adding build dependencies where required and setting variables that are
      set by the corresponding /cmake/FindXXX.cmake configs.
      
      There are a few things that should be noted separately though:
       - We dropped the ZLIB_FOUND check from the main project cmake config.
         It was used for building EE but the latter is going to be broken
         anyway once this patch is committed. We'll fix it in following
         commits.
       - FindLibUnwind referenced zlib library by ZLIB::ZLIB. We don't set
         it for bundled zlib so let's use ZLIB_LIBRARIES instead.
       - We don't need to detect dependency cflags while building bundled
         libraries as we can reuse the flags set by the main project.
       - We don't use HARDENING_LDFLAGS because it makes no sense when
         building static libraries.
      
      Closes #9242
      
      NO_DOC=build
      NO_TEST=build
      NO_CHANGELOG=build
      
      (cherry picked from commit 98b38e89)
      f3b31aee
    • Vladimir Davydov's avatar
      cmake: don't reexport static library API functions · d13498ef
      Vladimir Davydov authored
      There's no need in it because we closed Tarantool symbols long ago and
      now export only those symbols that are specified in exports files. Let's
      remove the useless code.
      
      Needed for #9242
      
      NO_DOC=build
      NO_TEST=build
      NO_CHANGELOG=build
      
      (cherry picked from commit 707ff97f)
      d13498ef
  8. Nov 02, 2023
    • Astronomax's avatar
      test: cover box_wait_limbo_acked · a44ed8cf
      Astronomax authored
      Prior to this patch, there were many possible code execution options
      that were not covered by tests. After this commit, any assert(false)
      inside box_wait_limbo_acked cause a crash.
      
      Closes #7318
      
      NO_DOC=test
      NO_CHANGELOG=test
      
      (cherry picked from commit 7fce5bec)
      a44ed8cf
  9. Oct 27, 2023
    • Nikolay Shirokovskiy's avatar
      small: bump version · 48ec9b5c
      Nikolay Shirokovskiy authored
      New commits:
      
      - test: fix test build for Debian 9 and alike
      - test: fix unused variable warning in matras test
      
      NO_TEST=submodule bump
      NO_CHANGELOG=submodule bump
      NO_DOC=submodule bump
      48ec9b5c
  10. Oct 26, 2023
    • Ilya Verbin's avatar
      box: improve error message raised on hash index replace failure · 7a316e1c
      Ilya Verbin authored
      Old: "Failed to allocate 2147483648 bytes in hash_table for key"
      New: "Failed to allocate 16384 bytes in hash_table for key"
      
      ERRINJ_INDEX_ALLOC cannot be used to test this error, because it fails
      earlier, so ERRINJ_HASH_INDEX_REPLACE is introduced.
      
      Follow-up #3594
      
      NO_DOC=minor
      NO_CHANGELOG=minor
      
      (cherry picked from commit 0a8043d1)
      7a316e1c
    • Nikolay Shirokovskiy's avatar
      iproto: clean accounting of processed messages in input buffers · 9b74cb80
      Nikolay Shirokovskiy authored
      Message body resides in one of rotating input buffers for the
      connection. When we don't need message body anymore we advance the
      reading end of the input buffer by the size of the message. But message
      processing order can differ from the order of messages in the wire.
      Thus this advancing a bit hacky. Let's instead mark the data in the
      input buffer as read when we process all the messages in the input
      buffer. We cannot reuse the buffer any earlier anyway.
      
      Follow-up #7327
      
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      NO_DOC=refactoring
      
      (cherry picked from commit 9e918278)
      9b74cb80
    • Nikolay Shirokovskiy's avatar
      misc: use ibuf API to discard/allocate/consume · 62c9e6ef
      Nikolay Shirokovskiy authored
      The API functions additionally poison related data in ASAN build.
      
      Follow-up #7327
      
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      NO_DOC=refactoring
      
      (cherry picked from commit 73832668)
      62c9e6ef
    • Vladimir Davydov's avatar
      util: add VERIFY macro · f0ba1e1e
      Vladimir Davydov authored
      The new macro is like assert, but it evaluates the checked expression
      even in the release mode.
      
      NO_DOC=internal
      NO_TEST=internal
      NO_CHANGELOG=internal
      
      (cherry picked from commit bfd2a20d)
      f0ba1e1e
    • Nikolay Shirokovskiy's avatar
      asan: turn ASAN allocators on finally · fbe2d58e
      Nikolay Shirokovskiy authored
      This patch also includes:
        - misc trivial fixes for ASAN discovered issues
        - minor adaptations for ASAN friendly allocators
      
      Closes #7327
      
      NO_DOC=internal
      NO_CHANGELOG=internal
      
      (cherry picked from commit 446201b8)
      fbe2d58e
    • Nikolay Shirokovskiy's avatar
      fiber: mark stack slab leak on mprotect fail as a non-leak · 19280319
      Nikolay Shirokovskiy authored
      With new ASAN-friendly small implementation unit/fiber_stack.c test
      start to fail. The issue is leak sanitizer reports a leak. This is an
      expected leak of test for mprotect failure on fiber stack destruction.
      Let's tell sanitizer to ignore this case.
      
      By the way let's drop test code for temporary redirecting stderr. It is
      outdated as test is TAP-compatible. It was a PITA as due to this
      redirection there was no leak report only error exit code.
      
      Part of #7327
      
      NO_CHANGELOG=internal
      NO_DOC=internal
      
      (cherry picked from commit 41844ffb)
      19280319
    • Nikolay Shirokovskiy's avatar
      asan: prepare for ASAN-friendly ibuf · 5576ee3b
      Nikolay Shirokovskiy authored
      ASAN-friendly implementation poisons memory after allocation with
      ibuf_alloc so we need to fix existing places in code where we access
      memory after allocation.
      
      Part of ibuf implementation is inline functions in headers. Thus ibuf
      implementation in Lua reimplement this parts. We add poison to these
      inline functions in ASAN-friedly implementation so we need add same poison
      in Lua implementation.
      
      Part of #7327
      
      NO_CHANGELOG=internal
      NO_DOC=internal
      
      (cherry picked from commit 4f542bb7)
      5576ee3b
    • Nikolay Shirokovskiy's avatar
      salad: get rid of core memory dependency · 5db3556f
      Nikolay Shirokovskiy authored
      We are going to include generated small_config.h into small allocator
      headers (currently it is only included in small source files).
      core/memory.h depends on small headers and salad/heap.h depends on
      core/memory.h. As a result we need to provide a way for salad/heap.h
      users to find small_config.h header.
      
      Instead let's drop dependency from core/memory.h as we only use it for
      typeof definition.
      
      Part of #7327
      
      NO_CHANGELOG=code cleanup
      NO_DOC=code cleanup
      
      (cherry picked from commit d01609a4)
      5db3556f
    • Nikolay Shirokovskiy's avatar
      fiber: disable fiber stack protection with ASAN temporarily · 00c7da5e
      Nikolay Shirokovskiy authored
      If leak sanitizer reaches the memory protected from read with mprotect
      it exhibits all sorts of odd behaviour. It can hang, can crash, can
      return errors with no leak backtraces.
      
      We use mprotect to create guard zones at the end of fiber stack so if
      stack is overflowed we get a signal and crash. We take protection off
      when fiber is destroyed. Unfortunately we do not destroy cords (and its
      fibers) which cancelled through cord_cancel_and_join. This is going to
      be addressed in patch for issue #8423 ("Get rid of pthread_cancel()").
      Until that moment let's disable protection for ASAN builds.
      
      Note that we did not hit this behaviour before because LSAN only scans
      memory allocated using malloc and regular slab cache uses mmap to get
      memory.
      
      Part of #7327
      
      NO_CHANGELOG=internal
      NO_DOC=internal
      
      (cherry picked from commit 2ee15793)
      00c7da5e
    • Nikolay Shirokovskiy's avatar
      fiber: make madvise(2) arguments page aligned with ASAN slab cache · 24cbcbe7
      Nikolay Shirokovskiy authored
      Regularly fiber stack slab is page aligned. So upper stack border is
      page aligned too when stack grows down. But with ASAN friendly slab
      cache implementation this border is not page aligned. As a result
      madvise call on stack may zero memory beyond stack slab which will cause
      heap corruption. In debug build corruption is detected by assertion:
      
      NO_WRAP
       >  Fatal glibc error: malloc.c:2593 (sysmalloc): assertion failed: (old_top
       >  == initial_top (av) && old_size == 0) || ((unsigned long) (old_size) >=
       >  MINSIZE && prev_inuse (old_top) && ((unsigned long) old_end & (pagesize
       >  - 1)) == 0)
      NO_WRAP
      
      Interestingly enough the issue can not be investigated using ASAN. The
      memory is zeroed by kernel code which is not instrumented so it is
      invisible for sanitizer.
      
      Looks like non-ASAN builds are not affected. Even if stack_size is
      not page aligned the slab allocated for stack is page aligned. Thus
      memory zeroing will be inside the slab and there will be no memory
      corruption.
      
      Also when stack grows up lower stack border in not aligned even with
      regular small implementation. So madvise call will fail with EINVAL as
      it is required that start address is page aligned. We ignore the error
      though. Let's fix this issue too while we at it.
      
      Let's introduce fiber_madvise_aligned to align madvise range with proper
      direction before calling madvise(2). To justify its usage note that
      besides fixing the issues described above, in case of stack growing down
      fiber->stack is page aligned and in case of stack growing up
      fiber->stack + fiber->stack_size is page aligned.
      
      Part of #7327
      
      NO_TEST=tested by ASAN (debug build)
      NO_CHANGELOG=has effect only with newly introduced ASAN friendly slab cache
      NO_DOC=has effect only with newly introduced ASAN friendly slab cache
      
      (cherry picked from commit 130c7807)
      24cbcbe7
    • Nikolay Shirokovskiy's avatar
      fiber: don't unpoison fiber stack · 8c1f93bf
      Nikolay Shirokovskiy authored
      The unpoison was added in the initial commit 1.7.2-68-gafd229393 that
      supported ASAN. It is not clear why do we need it as we don't poison
      stack memory manually.
      
      Part of #7327
      
      NO_TEST=removing unfunctional code
      NO_CHANGELOG=removing unfunctional code
      NO_DOC=removing unfunctional code
      
      (cherry picked from commit 0784f7b7)
      8c1f93bf
    • Mergen Imeev's avatar
      sql: remove legacy code from vdbesort.c · 96505c61
      Mergen Imeev authored
      This patch removes some deprecated code. This code had no user-visible
      effect, but caused problems when running the test with ASAN enabled.
      
      Closes #8761
      
      NO_DOC=refactoring
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      
      (cherry picked from commit d63a4bf2)
      96505c61
Loading