Detected memory leaks
Submitted by silvioprog
Assigned to mal..@..db.org
Link to original bug (#777860)
Description
Hello masters,
I opened a topic talking about some leaks in libgda: https://mail.gnome.org/archives/gnome-db-list/2017-January/msg00007.html . A very basic test to generate leaks:
=== begin ===
#include <libgda.h>
int main() { GdaConnection *cnc; gda_init(); cnc = gda_connection_open_from_string("SQLite", "DB_DIR=.;DB_NAME=test", NULL, GDA_CONNECTION_OPTIONS_NONE, NULL); g_object_unref(cnc); return EXIT_SUCCESS; }
================================================================= ==12278==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 72 byte(s) in 3 object(s) allocated from: #0 0x7f69088a0cdd in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xccdd) #1 (closed) 0x7f6906c5f780 in g_malloc0 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4f780)
Direct leak of 15 byte(s) in 3 object(s) allocated from: #0 0x7f69088a0795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795) #1 (closed) 0x7f690737d521 in xmlStrdup (/usr/lib/x86_64-linux-gnu/libxml2.so.2+0xd4521)
Indirect leak of 10 byte(s) in 1 object(s) allocated from: #0 0x7f69088a0795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795) #1 (closed) 0x7f6906c5f728 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4f728)
SUMMARY: LeakSanitizer: 97 byte(s) leaked in 7 allocation(s).
Process finished with exit code 23
== end ===
The first test was using latest libgda stable, but found leaks in version from trunk too. (6.0)
My CMake file:
=== begin ===
cmake_minimum_required(VERSION 3.6) project(testes)
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_FLAGS "-g -fsanitize=leak")
add_definitions(-I/usr/local/include/libgda-6.0) add_definitions(-I/usr/local/include/libgda-6.0/libgda) add_definitions(-I/usr/include/glib-2.0) add_definitions(-I/usr/lib/x86_64-linux-gnu/glib-2.0/include) add_definitions(-I/usr/include/libxml2)
set(SOURCE_FILES main.c) add_executable(testes ${SOURCE_FILES}) target_link_libraries(testes gda-6.0 gobject-2.0 gthread-2.0 pthread glib-2.0 xml2)
=== end ===
My environment:
OS Xubuntu 16.04 64 bits gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4) $ pkg-config glib-2.0 libgda-5.0 --modversion 2.48.1 5.2.4