[gnome-db] Leak reports



Hi!

I included parts of code and valgrind reports.
I am no lex expert so couldn't investigate #3 , and simply had no more
time for #4.
( BTW, is it possible to get svn account? Fixing such simple issues in
repository requires much less time than writing such mail )


# 1

const gchar *where = some_val_freed_outside_the_function;

if(where != NULL) {
	GdaQueryCondition *cond =
		gda_query_condition_new_from_sql(query, where, NULL, NULL); /* line 294 */
	gda_query_set_condition (query, cond);
}


g_debug("%s", gda_query_get_sql_text(query)); /* line 298 */
GError *error = NULL;
gda_query_execute(query, NULL, FALSE, NULL);
g_object_unref(query);

==16171== 10,215 bytes in 718 blocks are definitely lost in loss record
2,732 of 2,777
==16171==    at 0x40234B0: malloc (vg_replace_malloc.c:149)
==16171==    by 0x41BEDB5: g_malloc (in /usr/lib/libglib-2.0.so.0.1200.12)
==16171==    by 0x41D2238: g_strdup (in /usr/lib/libglib-2.0.so.0.1200.12)
==16171==    by 0x4125234: gda_query_field_field_get_ref_field_name
(gda-query-field-field.c:720)
==16171==    by 0x410D86F: gda_query_get_field_by_sql_naming_fields
(gda-query.c:3188)
==16171==    by 0x4110A0E: gda_query_get_field_by_sql_naming
(gda-query.c:3131)
==16171==    by 0x41326A1: parsed_create_field_query_field
(gda-query-parsing.c:1285)
==16171==    by 0x4133433: parsed_create_global_query_field
(gda-query-parsing.c:1190)
==16171==    by 0x4133E9D: parsed_create_simple_condition
(gda-query-parsing.c:1974)
==16171==    by 0x413454A: parsed_create_complex_condition
(gda-query-parsing.c:1878)
==16171==    by 0x411B601: gda_query_condition_new_from_sql
(gda-query-condition.c:364)
==16171==    by 0x44C0768: _midgard_core_query_insert_records
(midgard_core_query.c:294)

Clear leak is in gda_query_get_field_by_sql_naming_fields (gda-query.c:3188).
ref_name could be initialized with NULL value at the beginning and freed (
safely ) at the end.

==16171== 10,240 bytes in 10 blocks are definitely lost in loss record
2,733 of 2,777
==16171==    at 0x40235AB: realloc (vg_replace_malloc.c:306)
==16171==    by 0x41BEC7A: g_realloc (in /usr/lib/libglib-2.0.so.0.1200.12)
==16171==    by 0x41D320B: (within /usr/lib/libglib-2.0.so.0.1200.12)
==16171==    by 0x41D3732: g_string_insert_len (in
/usr/lib/libglib-2.0.so.0.1200.12)
==16171==    by 0x41D3B90: g_string_append (in
/usr/lib/libglib-2.0.so.0.1200.12)
==16171==    by 0x411A67A: gda_query_render_as_sql (gda-query.c:5654)
==16171==    by 0x411AF01: gda_query_get_sql_text (gda-query.c:1553)
==16171==    by 0x44C0782: _midgard_core_query_insert_records
(midgard_core_query.c:298)
==16171==    by 0x44C5E33: __insert_or_update_records (midgard_object.c:787)
==16171==    by 0x44C660D: _midgard_object_update (midgard_object.c:549)
==16171==    by 0x44C6D34: midgard_object_update (midgard_object.c:668)
==16171==    by 0x8049281: main (midgard-schema.c:84)

This is either code or documentation issue.
Quote from source:

" * Returns: the new string
 */
 const gchar *
"

So it should be 'gchar *' ( not const ) or 'Returns: sql string' ( not new ).
The string is returned either NULL or not freed from GString.
----------------------------------------------------------------------------

# 2

GdaDataModel *dm_schema =
	gda_connection_get_schema(mgd->priv->connection, /* line 319 */
		GDA_CONNECTION_SCHEMA_TABLES, NULL ,NULL);

	if(!dm_schema) {
		g_error("Failed to retrieve tables schema");
		return TRUE;
	}

	gint rows = gda_data_model_get_n_rows(dm_schema);
	guint j;
	const GValue *value;

	for(j = 0; j < rows; j++) {
		value = gda_data_model_get_value_at(dm_schema, 0, j);
		if(g_str_equal(g_value_get_string(value), tablename)){
			g_object_unref(dm_schema);
			return TRUE;
		}
	}

	g_object_unref(dm_schema);

==16171== 6,745 bytes in 1,349 blocks are definitely lost in loss record
2,716 of 2,777
==16171==    at 0x40234B0: malloc (vg_replace_malloc.c:149)
==16171==    by 0x41BEDB5: g_malloc (in /usr/lib/libglib-2.0.so.0.1200.12)
==16171==    by 0x41D2238: g_strdup (in /usr/lib/libglib-2.0.so.0.1200.12)
==16171==    by 0x414C02E: tranlex (lexer.l:59)
==16171==    by 0x414AA8C: tranparse (parser.c:1412)
==16171==    by 0x414C5F4: gda_sql_transaction_parse_with_error
(gda-sql-transaction-parser.c:100)
==16171==    by 0x40C5B40: gda_connection_internal_treat_sql
(gda-connection.c:1807)
==16171==    by 0x47F7B5A: process_sql_commands (gda-mysql-provider.c:530)
==16171==    by 0x47FA978: get_mysql_tables (gda-mysql-provider.c:1279)
==16171==    by 0x413F17D: gda_server_provider_get_schema
(gda-server-provider.c:930)
==16171==    by 0x40C5E53: gda_connection_get_schema (gda-connection.c:1558)
==16171==    by 0x44BFD8C: __table_exists (midgard_core_query.c:319)

--------------------------------------------------------------------

# 3

gvalue = gda_data_model_get_value_at(model, columns, rows);
if(G_IS_VALUE(gvalue)) {
	g_object_set_property(G_OBJECT(object), /* line 1021 */
		gda_data_model_get_column_title(model, columns), gvalue);
}

==16171== 504 bytes in 24 blocks are definitely lost in loss record 2,440
of 2,777
==16171==    at 0x40227EF: calloc (vg_replace_malloc.c:279)
==16171==    by 0x41BED1D: g_malloc0 (in /usr/lib/libglib-2.0.so.0.1200.12)
==16171==    by 0x4145D38: gda_binary_to_string (gda-value.c:2212)
==16171==    by 0x4148CF7: binary_to_string (gda-value.c:248)
==16171==    by 0x4067424: g_value_transform (in
/usr/lib/libgobject-2.0.so.0.1200.12)
==16171==    by 0x404B590: g_object_set_property (in
/usr/lib/libgobject-2.0.so.0.1200.12)
==16171==    by 0x44CEC01: _mqb_set_object_from_query (query_builder.c:1021)
==16171==    by 0x44CED24: midgard_query_builder_execute_or_count
(query_builder.c:559)
==16171==    by 0x44CF1F1: midgard_query_builder_execute
(query_builder.c:641)
==16171==    by 0x44DE0F4: midgard_object_set_parameter
(midgard_object_parameter.c:263)
==16171==    by 0x804926E: main (midgard-schema.c:74)

---------------------------------------------------------------------------

# 4

const gchar *query = some_val_freed_outside_the_function;
GdaCommand *command;
gint number;
command = gda_command_new(query,
	GDA_COMMAND_TYPE_SQL,
	GDA_COMMAND_OPTION_STOP_ON_ERRORS);
number  = gda_connection_execute_non_select_command( /* line 71 */
	mgd->priv->connection, command, NULL, NULL);
gda_command_free(command);

==16171== 336 bytes in 48 blocks are definitely lost in loss record 2,341
of 2,777
==16171==    at 0x40234B0: malloc (vg_replace_malloc.c:149)
==16171==    by 0x41BEDB5: g_malloc (in /usr/lib/libglib-2.0.so.0.1200.12)
==16171==    by 0x41D0C80: g_strndup (in /usr/lib/libglib-2.0.so.0.1200.12)
==16171==    by 0x41D0EFD: g_ascii_strup (in
/usr/lib/libglib-2.0.so.0.1200.12)
==16171==    by 0x47F7D5A: process_sql_commands (gda-mysql-provider.c:513)
==16171==    by 0x413FC90: gda_server_provider_execute_command
(gda-server-provider.c:642)
==16171==    by 0x40C80D5: gda_connection_execute_command
(gda-connection.c:1144)
==16171==    by 0x40C8258: gda_connection_execute_non_select_command
(gda-connection.c:1302)
==16171==    by 0x44C0DEE: midgard_core_query_execute
(midgard_core_query.c:71)
==16171==    by 0x44D64C7: midgard_quota_create (midgard_quota.c:229)
==16171==    by 0x44C6F03: _midgard_object_create (midgard_object.c:892)
==16171==    by 0x44C74AC: midgard_object_create (midgard_object.c:1009)


Already reported:

==16171== 5 bytes in 1 blocks are definitely lost in loss record 133 of 2,777
==16171==    at 0x40234B0: malloc (vg_replace_malloc.c:149)
==16171==    by 0x42B1D15: xmlStrndup (in /usr/lib/libxml2.so.2.6.28)
==16171==    by 0x42B1ED3: xmlStrdup (in /usr/lib/libxml2.so.2.6.28)
==16171==    by 0x425F78D: xmlNewDtd (in /usr/lib/libxml2.so.2.6.28)
==16171==    by 0x4252E6A: xmlSAXParseDTD (in /usr/lib/libxml2.so.2.6.28)
==16171==    by 0x4252F9F: xmlParseDTD (in /usr/lib/libxml2.so.2.6.28)
==16171==    by 0x4102096: gda_init (gda-init.c:125)
==16171==    by 0x8048E67: main (midgard-schema.c:142)

Shouldn't those be freed with xmlFreeDtd?
I mean some gda_close function , if gda_init already exists.

Piotras




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