https://bugs.kde.org/show_bug.cgi?id=455826

--- Comment #3 from shapath <meeee...@gmail.com> ---
Thank you guys for the response !!!
The leak is reported in third-party code. Based on your responses and input I
analyzed the code and wrote a similar sample program where i was able to hit
this.

The interesting thing I found is it is related to packing. If I do not use
packing I do not see this issue.


Here is the sample code:
======================

#include  <stdio.h>
#include  <stdlib.h>
#include <string.h>

#define YPACK __attribute__((packed))
//#define YPACK

typedef struct sample_t
{
    unsigned short        header;
    struct sample_t       *prev;
    struct sample_t       *next;
} YPACK MY_Node;


typedef  struct abc
{
   MY_Node node;
   char *name;
} YPACK xyz;

//Global

xyz *node;

void* my_malloc(char **t)
{
   {
      *t  = strdup("hello");
   }
}

void main()
{
   char *t;
   node = malloc(sizeof(xyz));
   my_malloc(&(node->name));

   while(1)
      sleep();
   //free(t);

   return;
}


Valgrind report:-
==============
(gdb) monitor leak_check full reachable any
==30830== 6 bytes in 1 blocks are definitely lost in loss record 1 of 2
==30830==    at 0x4C29F73: malloc (vg_replace_malloc.c:309)
==30830==    by 0x4EC3B89: strdup (in /usr/lib64/libc-2.17.so)
==30830==    by 0x4005D2: my_malloc (valgrind.c:29)
==30830==    by 0x400606: main (valgrind.c:37)
==30830==
==30830== 26 bytes in 1 blocks are still reachable in loss record 2 of 2
==30830==    at 0x4C29F73: malloc (vg_replace_malloc.c:309)
==30830==    by 0x4005EC: main (valgrind.c:36)
==30830==
==30830== LEAK SUMMARY:
==30830==    definitely lost: 6 bytes in 1 blocks
==30830==    indirectly lost: 0 bytes in 0 blocks
==30830==      possibly lost: 0 bytes in 0 blocks
==30830==    still reachable: 26 bytes in 1 blocks
==30830==         suppressed: 0 bytes in 0 blocks
==30830==


Thanks
Shapath

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to