Re: [gnome-db] Newbie question: do why I get this memory leak?



Unfortunately, same problem in copy installed from trunk (libgda-6.0):
#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 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 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 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

On Thu, Jan 26, 2017 at 11:55 PM, silvioprog <silvioprog gmail com> wrote:
Same problem in full example: https://developer.gnome.org/libgda/stable/main_example.html . :-/

ref   | name  | price   
------+-------+---------
p1    | chair | 2.000000
p2    | table | 5.000000
p3    | glass | 1.100000
p1000 | ???   |     NULL
p1001 | ???   |     NULL
(5 rows)
ref   | name    | price   
------+---------+---------
p1    | chair   | 2.000000
p2    | table   | 5.000000
p3    | glass   | 1.100000
p1000 | flowers | 1.990000
p1001 | ???     |     NULL
(5 rows)
ref   | name    | price   
------+---------+---------
p1    | chair   | 2.000000
p3    | glass   | 1.100000
p1000 | flowers | 1.990000
(3 rows)

=================================================================
==9425==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 72 byte(s) in 3 object(s) allocated from:
    #0 0x7f61eb99acdd in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xccdd)
    #1 0x7f61eb6cc780 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 0x7f61eb99a795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
    #1 0x7f61e9cf5521 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 0x7f61eb99a795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
    #1 0x7f61eb6cc728 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

On Thu, Jan 26, 2017 at 11:16 PM, silvioprog <silvioprog gmail com> wrote:
Hello masters, I'm newbie here.

Well, I need to develop a DB application, so libgda will help me a lot in that task. However, doing some two basic tests, I found memory in both:
#include <libgda.h>

int main() {
GdaConnection *connection;
g_print("CONNECTING\n");
connection = gda_connection_open_from_dsn("calvaris", NULL, GDA_CONNECTION_OPTIONS_READ_ONLY, NULL);
if (!connection) {
g_print("CONNECTION FAILED\n");
return EXIT_FAILURE;
}
g_print("CONNECTED\n");
g_object_unref(G_OBJECT (connection));
return EXIT_SUCCESS;
}
result:

CONNECTING
CONNECTION FAILED

=================================================================
==6364==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 72 byte(s) in 3 object(s) allocated from:
    #0 0x7fa242cd0cdd in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xccdd)
    #1 0x7fa242a02780 in g_malloc0 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4f780)

Indirect leak of 10 byte(s) in 1 object(s) allocated from:
    #0 0x7fa242cd0795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
    #1 0x7fa242a02728 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4f728)

SUMMARY: LeakSanitizer: 82 byte(s) leaked in 4 allocation(s).

Process finished with exit code 23

Same leak using a valid connection:
#include <libgda.h>

int main() {
GdaConnection *connection;
g_print("CONNECTING\n");
connection = gda_connection_open_from_string("SQLite", "DB_DIR=.;DB_NAME=test.sqlite3", NULL, GDA_CONNECTION_OPTIONS_NONE, NULL);
if (!connection) {
g_print("CONNECTION FAILED\n");
return EXIT_FAILURE;
}
g_print("CONNECTED\n");
g_object_unref(G_OBJECT (connection));
return EXIT_SUCCESS;
}
result:

CONNECTING
CONNECTED

=================================================================
==6734==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 72 byte(s) in 3 object(s) allocated from:
    #0 0x7f4f60ea3cdd in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xccdd)
    #1 0x7f4f60bd5780 in g_malloc0 (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4f780)

Indirect leak of 10 byte(s) in 1 object(s) allocated from:
    #0 0x7f4f60ea3795 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/liblsan.so.0+0xc795)
    #1 0x7f4f60bd5728 in g_malloc (/lib/x86_64-linux-gnu/libglib-2.0.so.0+0x4f728)

SUMMARY: LeakSanitizer: 82 byte(s) leaked in 4 allocation(s).

Process finished with exit code 23

Why?! :-/

My CMake file:
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-5.0)
add_definitions(-I/usr/local/include/libgda-5.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 pthread glib-2.0 gobject-2.0 gda-5.0)
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

Thank you!

--
Silvio Clécio



--
Silvio Clécio



--
Silvio Clécio


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]