• Alexander Barkov's avatar
    MDEV-16614 signal 7 after calling stored procedure, that uses regexp · 5c5a116b
    Alexander Barkov authored
    The problem happened in the derived condition pushdown code:
    - When Item_func_regex::build_clone() was called, it created a copy of
      the original Item_func_regex, and this copy got registered in free_list.
      Class specific additional dynamic members (such as "re") made
      a shallow copy, rather than a deep copy, in the cloned Item_func_regex.
      As a result, the Regexp_processor_pcre::m_pcre of the cloned Item_func_regex
      and of the original Item_func_regex pointed to the same compiled regular
      expression.
    - On cleanup_items(), both original and cloned copies of Item_func_regex
      called re.cleanup(), which called pcre_free(m_pcre). So the same compiled
      regular expression was freed two times, which was noticed by ASAN.
    
    The same problem was repeatable for Item_func_regexp_instr.
    
    A similar problem happened for Item_func_sp, for the sp_result_field member.
    Both original and cloned copies of Item_func_sp pointed the same Field instance
    and both deleted it on cleanup().
    
    A possible solution would be to fix build_clone() to create deep
    (instead of shallow) copies for the dynamic members of the affected classes
    (Item_func_regex, Item_func_regexp_instr, Item_func sp).
    However, this would be too complex.
    
    As agreed with Galina and Igor, this patch disallows using using these
    affected classes in derived condition pushdown by overriding get_clone()
    to return NULL.
    5c5a116b
item_cmpfunc.h 91.3 KB