Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-39380

MariaDB debug build assertion `arg2_int >= 0' failed in Item_func_additive_op::result_precision

    XMLWordPrintable

Details

    • Can result in hang or crash
    • Hide
      A 0xHHHH / b'..' literal kept its hex_hybrid type through COALESCE/IF/CASE/..., but was evaluated, sized and stored as a string, so it behaved differently from a bare literal (10+COALESCE(0x31) gave 11, not 59); type_handler_hex_hybrid now implements the numeric side to match the bare literal: val_int/val_real/val_decimal read bytes as a hybrid, Item_decimal_precision returns the integer precision, Item_save_in_field stores like the bare literal; the traditional type merge keeps the hybrid through a typeless NULL (as for BIT), and Item_hybrid_func_fix_attributes attributes it binary/unsigned
      Show
      A 0xHHHH / b'..' literal kept its hex_hybrid type through COALESCE/IF/CASE/..., but was evaluated, sized and stored as a string, so it behaved differently from a bare literal (10+COALESCE(0x31) gave 11, not 59); type_handler_hex_hybrid now implements the numeric side to match the bare literal: val_int/val_real/val_decimal read bytes as a hybrid, Item_decimal_precision returns the integer precision, Item_save_in_field stores like the bare literal; the traditional type merge keeps the hybrid through a typeless NULL (as for BIT), and Item_hybrid_func_fix_attributes attributes it binary/unsigned

    Description

      MariaDB debug build (12.2.2-MariaDB-asan-debug) crashes with an assertion failure when performing subtraction with SUM of COALESCE on binary literal. The assertion `arg2_int >= 0` fails in `Item_func_additive_op::result_precision()`.

      DROP DATABASE IF EXISTS sqlcraft;
      CREATE DATABASE sqlcraft;
      USE sqlcraft;
       
      SELECT ( 3.14159 ) - ( ( SUM( COALESCE( b'101010' ) ) ) / ( 42 ) ) AS c4 ;
      

      crash logs:
       
      mariadbd: /app/dbms/mariadb-12.2.2/sql/item_func.cc:1287: virtual void Item_func_additive_op::result_precision(): Assertion `arg2_int >= 0' failed.
      260420  9:55:34 [ERROR] /usr/local/mariadb-asan/bin/mariadbd got signal 6 ;
      Sorry, we probably made a mistake, and this is a bug.
       
      Your assistance in bug reporting will enable us to fix this for the next release.
      To report this bug, see https://mariadb.com/kb/en/reporting-bugs about how to report
      a bug on https://jira.mariadb.org/.
       
      Server version: 12.2.2-MariaDB-asan-debug source revision: d26a6f44c1f2119377e79a9540886c6d8c01472f
       
      Query (0x52d00024e438): SELECT ( 3.14159 ) - ( ( SUM( COALESCE( b'101010' ) ) ) / ( 42 ) ) AS c4
      Status: NOT_KILLED
      

      Attachments

        Issue Links

          Activity

            People

              alice Alice Sherepa
              ammmkilo ammmkilo
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0d
                  0d
                  Logged:
                  Time Spent - 1h
                  1h

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.