[MDEV-24476] Overloaded functions dbug_print_rec break compilation in 10.3 Created: 2020-12-23  Updated: 2020-12-24  Resolved: 2020-12-24

Status: Closed
Project: MariaDB Server
Component/s: Debug, Storage Engine - InnoDB
Affects Version/s: 10.3.28
Fix Version/s: 10.3.28

Type: Bug Priority: Major
Reporter: Dmitry Shulga Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: None
Environment:

MacOS


Issue Links:
Problem/Incident
is caused by MDEV-21138 Assertion `col->ord_part' or `f.col->... Closed

 Description   

Implementations of overloaded standalone functions dbug_print_rec, located in the file storage/innobase/ut/ut0ut.cc, return pointer to a temporary allocated memory. In result attempt to compile server on MacOS fails with error

[ 18%] Building CXX object storage/innobase/CMakeFiles/innobase.dir/ut/ut0ut.cc.o
10.3/storage/innobase/ut/ut0ut.cc:635:9: error: returning address
      of local temporary object [-Werror,-Wreturn-stack-address]
        return r.str().c_str();
               ^~~~~~~
10.3/storage/innobase/ut/ut0ut.cc:641:9: error: returning address
      of local temporary object [-Werror,-Wreturn-stack-address]
        return r.str().c_str();
               ^~~~~~~
10.3/storage/innobase/ut/ut0ut.cc:647:9: error: returning address
      of local temporary object [-Werror,-Wreturn-stack-address]
        return r.str().c_str();
               ^~~~~~~
10.3/storage/innobase/ut/ut0ut.cc:653:9: error: returning address
      of local temporary object [-Werror,-Wreturn-stack-address]
        return r.str().c_str();
               ^~~~~~~
10.3/storage/innobase/ut/ut0ut.cc:665:9: error: returning address
      of local temporary object [-Werror,-Wreturn-stack-address]
        return r.str().c_str();
               ^~~~~~~
5 errors generated.

The overloaded function dbug_print_rec() isn't used anywhere along the source code.
So, it is proposed to remove them at all.



 Comments   
Comment by Sergei Golubchik [ 2020-12-23 ]

no, they are supposed to be used from the gdb prompt, don't remove.
typically other dbug_print* functions use a static buffer. Like

#ifndef DBUG_OFF
char dbug_print_buffer[1024];
const char *dbug_print_rec(...)
{
  strmake(dbug_print_buffer, r.str().c_str(), sizeof(dbug_print_buffer)-1);
  return dbug_print_buffer;
}

Generated at Thu Feb 08 09:30:17 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.