I am working on a open source tool "zabbix" and it works very fine on RHEL/ Global Zone of Solaris 10. But the problem seems confusing when I try to run this tool on a sparse zone of Solaris 10. On the sparse zone, the tool works sometimes and sometimes it crashes with SIGSEGV signal. This signal is raised while freeing up the memory allocated by a variable.
Please see below the exact codes where this signal is raised:
void free_request(AGENT_REQUEST *request)
{
int i;
zbx_free(request->key);
for (i = 0; i < request->nparam; i++)
zbx_free(request->params[i]);
zbx_free(request->params);
request->nparam = 0;
}
Please be informed that this part of code runs flawlessly on Linux or any Global Zone of Solaris 10.
Now, you might point that may be zbx_free() is trying to free some variable which is already free. I would say, NO. because I have debugged the code and found that the allocation of the variable was legitimate before zbx_free() tried to free the variable and consequently raised SIGSEVG signal.
You may want to look into the macro zbx_free(request->key)
(It is a macro but function). Please see below, as this is very simple too.
do \
{ \
if (request->key) \
{ \
free(request->key); \
request->key = ((void *)0); \
} \
} \
while (0)
So, In my opinion the question hovers between "sparse zone" and "Global zone". I assume, Global zone is restricting sparse zone to free() memory allocation. If it is true, then could someone please help me to solve this issue? Please suggest me the workaround, if any.
Thanks for your time.
Regards,
Rohit