[redland-dev] librdf_model_context_add_statements() assertion failure, and a query-related crash

René Puls kianga at gmail.com
Sat Jul 3 00:26:19 BST 2004


Hi,

I found two more problems with the Redland library:

First, when I call librdf_model_context_add_statements() with a NULL
context, I get an assertion failure:

rdf_storage.c:1117: (librdf_storage_context_add_statements) assertion
failed: object pointer of type librdf_statement is NULL.

The documentation for this function says: "If context is NULL, this is
equivalent to librdf_model_add_statements".

http://www.redland.opensource.ac.uk/docs/api/r1703.html
http://www.redland.opensource.ac.uk/docs/api/r8489.html

The assertion itself seems to be wrong too, because the offending line
(rdf_storage.c:1123) says:

LIBRDF_ASSERT_OBJECT_POINTER_RETURN_VALUE(context, librdf_statement, 1);

... even though the context parameter is a librdf_node. The same
problem exists in the singular version of this function,
librdf_storage_context_add_statement.

The second problem is a crash when using RDF queries. For some reason
I can't reproduce this with a small test program. It only happens in
my larger Python program, which I currently cannot post here. The
problematic lines are:

queryString = "SELECT ?a ?c WHERE (?a dc:title ?c) " + \
              "USING dc FOR <http://purl.org/dc/elements/1.1/>"

myQuery = RDF.Query(queryString)
results = myQuery.execute(coreModel)

for result in results:
	print result['a']
	print result['c']

The myQuery.execute() line crashes Python with the following stack trace:

Exception:  EXC_BAD_ACCESS (0x0001)
Codes:      KERN_PROTECTION_FAILURE (0x0002) at 0x00000000

Thread 0 Crashed:
0   librdf.0.dylib                      0x0064408c
librdf_new_uri_relative_to_base + 0x1c (rdf_uri.c:315)
1   <<00000000>>        0x00000002 0 + 0x2
2   librasqal.0.dylib                   0x0029902c rdql_lexer_lex +
0x640 (rdql_lexer.l:250)
3   librasqal.0.dylib                   0x0029ac20 rdql_parser_parse +
0x13c (rdql_parser.tab.c:1169)
4   librasqal.0.dylib                   0x0029b468 rdql_parse + 0x90
(rdql_parser.y:666)
5   librasqal.0.dylib                   0x0029d6ac
rasqal_query_prepare + 0xe0 (rasqal_query.c:565)
6   librdf.0.dylib                      0x00656c34
librdf_query_rasqal_execute + 0x2c (rdf_query_rasqal.c:488)
7   librdf.0.dylib                      0x006559ac
librdf_query_execute + 0x70 (rdf_query.c:414)
8   Redland.so                          0x002497ac
_wrap_librdf_query_execute + 0x98 (Redland_wrap.c:2894)
9   org.python.Python.framework         0x95fa94a8 PyEval_GetFuncDesc + 0x1dc
10  org.python.Python.framework         0x95fa6c64 PyEval_EvalCode + 0x2560
11  org.python.Python.framework         0x95fa9728 PyEval_GetFuncDesc + 0x45c
12  org.python.Python.framework         0x95fa9580 PyEval_GetFuncDesc + 0x2b4
13  org.python.Python.framework         0x95fa6c64 PyEval_EvalCode + 0x2560
14  org.python.Python.framework         0x95fa7e30 PyEval_EvalCodeEx + 0x850
15  org.python.Python.framework         0x95fa4734 PyEval_EvalCode + 0x30
16  org.python.Python.framework         0x95fc85f0 PyRun_FileExFlags + 0xe4
17  org.python.Python.framework         0x95fc7668
PyRun_SimpleFileExFlags + 0x1bc
18  org.python.Python.framework         0x95fd1ec0 Py_Main + 0x7cc
19  python                              0x00003c78 start + 0x1bc
20  python                              0x00003aec start + 0x30

But again, this only happens when executed in the larger program.

The workaround is quite easy: just add
base_uri=RDF.Uri("http://foo.bar/") to the RDF.Query() constructor. I
guess the problem here is that the base_uri parameter is not listed as
being required, while it is in fact a required parameter.

Kind regards,
René Puls



More information about the redland-dev mailing list