MDEV-25329: Assertion `allocated_status_memory != __null' failed in void PROF_MEASUREMENT::set_label(const char*, const char*, const char*, unsigned int)

Make profiler to play a bit better with memory allocators. Test suite can not be included because it lead to non free memory on shutdown (IMHO OK for memory shortage emulation)

As alternetive all this should be rewritten and ability to return errors on upper level should be added.
This commit is contained in:
Oleksandr Byelkin 2023-09-27 13:55:39 +02:00
parent 01031f43d8
commit d914d09f58
2 changed files with 13 additions and 2 deletions

View File

@ -203,7 +203,8 @@ void PROF_MEASUREMENT::set_label(const char *status_arg,
sizes[2]= (file_arg == NULL) ? 0 : strlen(file_arg) + 1;
allocated_status_memory= (char *) my_malloc(sizes[0] + sizes[1] + sizes[2], MYF(0));
DBUG_ASSERT(allocated_status_memory != NULL);
if (!allocated_status_memory)
return;
cursor= allocated_status_memory;
@ -267,6 +268,8 @@ QUERY_PROFILE::QUERY_PROFILE(PROFILING *profiling_arg, const char *status_arg)
{
m_seq_counter= 1;
PROF_MEASUREMENT *prof= new PROF_MEASUREMENT(this, status_arg);
if (!prof)
return;
prof->m_seq= m_seq_counter++;
m_start_time_usecs= prof->time_usecs;
m_end_time_usecs= m_start_time_usecs;
@ -308,6 +311,8 @@ void QUERY_PROFILE::new_status(const char *status_arg,
prof= new PROF_MEASUREMENT(this, status_arg, function_arg, base_name(file_arg), line_arg);
else
prof= new PROF_MEASUREMENT(this, status_arg);
if (!prof)
DBUG_VOID_RETURN;
prof->m_seq= m_seq_counter++;
m_end_time_usecs= prof->time_usecs;

View File

@ -98,6 +98,8 @@ public:
struct queue_item *new_item;
new_item= (struct queue_item *) my_malloc(sizeof(struct queue_item), MYF(0));
if (!new_item)
return;
new_item->payload= payload;
@ -291,7 +293,11 @@ public:
{
DBUG_ASSERT(!current);
if (unlikely(enabled))
current= new QUERY_PROFILE(this, initial_state);
{
QUERY_PROFILE *new_profile= new QUERY_PROFILE(this, initial_state);
if (new_profile)
current= new_profile;
}
}
void discard_current_query();