Skip to content
Snippets Groups Projects
  1. Dec 02, 2023
    • 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
  2. 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
    • Sergey Vorontsov's avatar
      ci: remove using Docker container in source.yml · 996025c5
      Sergey Vorontsov authored
      In this commit, we're fixing a problem with Docker in the workflow
      `.github/workflows/source.yml`.
      
      The mentioned workflow uses the `.github/actions/environment` action
      that needs a permission to make a loopback device for [1]. We didn't
      allow for that before due to missing container args, and it caused the
      following error:
      
      ```
      umount: /tmp/luajit-test-vardir: must be superuser to unmount.
      256000+0 records in
      256000+0 records out
      1048576000 bytes (1.0 GB, 1000 MiB) copied, 1.36702 s, 767 MB/s
      mount: /tmp/luajit-test-vardir: mount failed: Operation not permitted.
      Error: Process completed with exit code 1.
      ```
      
      The problem started since commit af996bbb ("ci: dockerize
      linux workflows"). The simplest way to fix the issue is not to run
      the workflow inside a Docker container because a tarball with the
      source code is created via the `./packpack/packpack tarball` command
      that runs a Docker container as well.
      
      [1] https://github.com/tarantool/tarantool/issues/7472
      
      NO_DOC=ci
      NO_TEST=ci
      NO_CHANGELOG=ci
      
      (cherry picked from commit 09ad57f4)
      Unverified
      996025c5
    • 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
    • Sergey Vorontsov's avatar
      ci: dockerize linux workflows · a9db25ae
      Sergey Vorontsov authored
      Modify Linux workflows for running jobs inside Docker containers. It
      helps isolate the building and testing environment from the runner's
      system and other workflows.
      
      Closes tarantool/tarantool-qa#327
      
      NO_DOC=ci
      NO_TEST=ci
      NO_CHANGELOG=ci
      
      (cherry picked from commit af996bbb)
      a9db25ae
  3. 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)
      Unverified
      b5b37629
  4. Nov 23, 2023
    • Sergey Vorontsov's avatar
      ci: use GitHub-hosted runner to upload sources · e296e312
      Sergey Vorontsov authored
      In the `.github/workflows/source.yml` workflow for preparing a tarball
      with the source code, a PackPack Docker container is already used. For
      uploading the tarball to the repo, the `aws` utility is used, which is
      installed before. To skip installation of additional packages on the
      self-hosted runners, we are moving to the GitHub-hosted runners, which
      already have the `aws` utility installed. Step `Prepare checkout` is
      removed because the GitHub-hosted runner is an ephemeral environment.
      
      NO_DOC=ci
      NO_TEST=ci
      NO_CHANGELOG=ci
      
      (cherry picked from commit 3ee68d8b)
      Unverified
      e296e312
  5. Nov 22, 2023
  6. Nov 21, 2023
    • Igor Munkin's avatar
      luajit: bump new version · d953b064
      Igor Munkin authored
      * Mark CONV as non-weak, to prevent elimination of its side-effect.
      * Fix ABC FOLD rule with constants.
      * test: add test for conversions folding
      * Add NaN check to IR_NEWREF.
      * LJ_GC64: Fix lua_concat().
      * test: introduce asserts assert_str{_not}_equal
      * ci: enable codespell
      * cmake: introduce target with codespell
      * codehealth: fix typos
      * tools: add cli flag to run profile dump parsers
      * profilers: purge generation mechanism
      * memprof: refactor symbol resolution
      * sysprof: fix crash during FFUNC stream
      * Fix last commit.
      * Print errors from __gc finalizers instead of rethrowing them.
      * x86/x64: Fix math.ceil(-0.9) result sign.
      * test: fix flaky fix-jit-dump-ir-conv.test.lua
      * IR_MIN/IR_MAX is non-commutative due to underlying FPU ops.
      * Fix jit.dump() output for IR_CONV.
      * Fix FOLD rule for x-0.
      * FFI: Fix pragma push stack limit check and throw on overflow.
      * Prevent compile of __concat with tailcall to fast function.
      * Fix base register coalescing in side trace.
      * Fix register mask for stack check in head of side trace.
      * x64: Properly fix __call metamethod return dispatch.
      
      Closes #8594
      Closes #8767
      Closes #9339
      Part of #9145
      
      NO_DOC=LuaJIT submodule bump
      NO_TEST=LuaJIT submodule bump
      d953b064
  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: fix bundled zzip install dir · 665129e2
      Vladimir Davydov authored
      zzip is installed to lib64/ on some systems by default so we need to
      explicitly set the install dir to lib/.
      
      Fixes commit 140fd681 ("cmake: allow to use bundled zzip").
      
      NO_DOC=build
      NO_TEST=build
      NO_CHANGELOG=build
      
      (cherry picked from commit a2311666)
      665129e2
    • Vladimir Davydov's avatar
      cmake: enable static linking of OpenSSL if BUILD_STATIC is set · 3df0f94f
      Vladimir Davydov authored
      Currently, the BUILD_STATIC and BUILD_STATIC_WITH_BUNDLED_LIBS cmake
      options don't enable static linking of the OpenSSL library so we have
      to set OPENSSL_USE_STATIC_LIBS explicitly. Let's enable static linking
      of OpenSSL by default because we enable it anyway in all our official
      builds.
      
      NO_DOC=build
      NO_TEST=build
      NO_CHANGELOG=build
      
      (cherry picked from commit edadffd7)
      3df0f94f
    • 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 use bundled zzip · 48a9ec56
      Vladimir Davydov authored
      There's EMBED_LUZIP cmake option that embeds the Lua zip module in
      Tarantool binary. Since the Lua zip module depends on the zzip library,
      it also links the zzip library. The option is used only by Tarantool EE
      so there's no config for bundling the zzip library in the CE repository.
      Now, that we bundle all static build dependencies in the main project
      cmake config, let's add zzip bundling code here as well. The code of
      /cmake/BuildZZIP.make is copied from /static-build/CMakeLists.txt of
      the EE repository.
      
      Follow-up #9242
      
      NO_DOC=build
      NO_TEST=build
      NO_CHANGELOG=build
      
      (cherry picked from commit 140fd681)
      48a9ec56
    • 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: build bundled libyaml as external project · 99a5ac16
      Vladimir Davydov authored
      Currently, we simply include the libyaml source directory into the main
      project. The problem is that libyaml uses ICU. If ICU is built outside
      the main project cmake config, as it's the case with the static-build,
      both the main project and libyaml cmake configs will use the same ICU
      version. However, if we build ICU in the main project, as we intend to
      do to resolve #9242, it may not work. To fix that, we need to use the
      external project API to build libyaml.
      
      Needed for #9242
      
      NO_DOC=build
      NO_TEST=build
      NO_CHANGELOG=build
      
      (cherry picked from commit 8820f5c9)
      99a5ac16
    • 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
    • Vladimir Davydov's avatar
      test: move Lua tests from /static-build/test to /test/app-tap · 4aa819bd
      Vladimir Davydov authored
      The tests are TAP compatible and applicable to all Tarantool builds so
      there's no need to run them with ctest. We just need to add a couple
      skip conditions:
       - The luarocks test shouldn't be run on dynamic builds because luarocks
         modules aren't embedded there.
       - The traceback test should be run only if ENABLE_BACKTRACE was set at
         build time.
      
      Part of #9242
      
      NO_DOC=refactoring
      NO_TEST=refactoring
      NO_CHANGELOG=refactoring
      
      (cherry picked from commit 1eb98ef3)
      4aa819bd
  8. Nov 03, 2023
    • Igor Munkin's avatar
      luajit: bump new version · f26262fc
      Igor Munkin authored
      * Revert "Update cur_L on exceptional path (arm)"
      * Revert "arm64: fix cur_L restoration on error throw"
      * Revert "Update cur_L on exceptional path"
      * Revert "Fix cur_L tracking on exceptional path"
      * Restore cur_L for specific Lua/C API use case.
      * Fix Clang build.
      
      Closes #6323
      Part of #9145
      
      NO_DOC=LuaJIT submodule bump
      NO_TEST=LuaJIT submodule bump
      f26262fc
  9. 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
  10. 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
  11. 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
    • Ilya Verbin's avatar
      log: add changelog and doc for "fix matras_view::block_count overflow" · a3e40481
      Ilya Verbin authored
      The issue is fixed in the `small' submodule by the following commit:
      
      * matras: fix matras_view::block_count overflow
      
      Closes #3594
      
      NO_TEST=The test requires more than 64 GB of RAM.
      
      @TarantoolBot document
      Title: Document maximum number of tuples in hash index
      Product: Tarantool
      Root document: https://www.tarantool.io/en/doc/latest/book/box/limitations/
      
      Number of tuples in hash index: 2147483648
      
      (cherry picked from commit 7eaa2d23)
      a3e40481
    • Vladimir Davydov's avatar
      Add changelog for gh-9218 · b61d9530
      Vladimir Davydov authored
      The bug was fixed in the small library:
       - slab: fix NULL ptr deref in assertion in slab_get
         https://github.com/tarantool/small/commit/ef77efacd452cb90caea2caf22d266f791c95ec3
       - slab: fix uint32_t overflow in slab_capacity
         https://github.com/tarantool/small/commit/77203600a7c645d97bce56f901eec25de0b29d6e
      
      The small library submodule was updated in commit ebafd684
      ("small: bump version").
      
      Closes #9218
      
      NO_DOC=changelog
      NO_TEST=changelog
      
      (cherry picked from commit 1fc6b4a1)
      b61d9530
    • Nikolay Shirokovskiy's avatar
      test: cherry-pick fix for memtx_gc_after_snapshot_test · 3cb72635
      Nikolay Shirokovskiy authored
      This is part of master commit bd4c6675 ("memtx: use MemtxAllocator
      stats for box.info.memory"). The test is failed without the patch in
      ASAN build.
      
      Follow-up #7327
      
      NO_CHANGELOG=test fix
      NO_DOC=test fix
      3cb72635
    • 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
      test: increase expected selectG execution time for debug ASAN build · 5d753c1e
      Nikolay Shirokovskiy authored
      The test is quite a flacky in debug ASAN CI workflow. The issue is test
      check upper boundary of it's execution time. I run many instances of
      this test on in parallel and got average time of 40s for memtex and 70s
      for vinyl.
      
      The time quota is already changed by the commit 84cb1e04 ("sql:
      increase time quota for selectG test on vinyl") for laptops with HDD.
      I did not check execution time for HDD though. I guess the bottleneck
      for debug ASAN is CPU.
      
      Follow-up #7327
      
      NO_CHANGELOG=internal
      NO_DOC=internal
      
      (cherry picked from commit 703d11fe)
      5d753c1e
    • 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: suppress leak reports caused by JIT · 26b8a326
      Nikolay Shirokovskiy authored
      With ASAN-friendly small allocators there are a lot test failures due
      to leak reports which are gone if JIT is off.
      
      Fortunately all the reports related to a few functions. Let's suppress
      temporarily such reports.
      
      Part of #7327
      
      NO_TEST=internal
      NO_CHANGELOG=internal
      NO_DOC=internal
      
      (cherry picked from commit f0feb923)
      26b8a326
    • Nikolay Shirokovskiy's avatar
      asan: adapt misc stats test for ASAN · 43ab2d40
      Nikolay Shirokovskiy authored
      When SMALL_MALLOC_IMPL is defined and ASAN-friendly allocators are used
      the arena allocator is not used at all as we not allocate memory
      directly from there. And other ASAN-friendly allocators are not allocate
      from it too. Thus box.slab.info().arena_size == 0. Same for usage
      of runtime arena box.runtime.info().used.
      
      Also usage with ASAN-friendly lsregion is a bit different as it does
      not account for size of alignment padding. Thus we need to adapt
      box.stat.vinyl().memory.level0 tests. Approach is to check for lower
      and upper limit instead of checking for exact values.
      
      Part of #7327
      
      NO_DOC=test changes
      NO_CHANGELOG=test changes
      
      (cherry picked from commit 1436eb41)
      43ab2d40
    • 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
Loading