Hi Artyom,
I seem to have some kind of memory corruption happening during copy
construction of cppdb::result.
This is the scenario:
An asynchronous service (JSON-RPC server) holds a pointer to a synchronous
service to obtain some results from the database. The synchronous service
lives as long as the asynchronous
attach(new Engine(srv, new RPC(srv, new Engine(srv))), "engine",
"/engine{1}", "/engine(/(.*))?", 1);
Engine is the synchronous service, RPC is the asynchronous.
The Engine constructor:
Engine::Engine(cppcms::service& srv, apps::tracker::RPC* p): Base(srv)
{
attach(p, "rpc", "/rpc{1}", "/rpc", 0);
}
RPC Constructor:
RPC::RPC(cppcms::service& srv, apps::tracker::Base* p):
json_rpc_server(srv), ctr_(p)
{
using namespace cppcms::rpc;
attach(ctr_);
bind("load_move_item_form", json_method(&RPC::load_move_item_form,
this), method_role);
}
the load_move_item_form function does something like this:
ctr_->init();
cppdb::result r = ctr_->get_all_items(aircraft_id, tbl, 0, false);
ctr_->clear()
the problem is the result r contains garbage, random memory.
the get_all_items function works fine when called from a synchronous
application though.
the backend is SQLite.
This is running on Mageia Linux with stock standard cppcms-1.0.3 and
cppdb-0.3.1
If I loop through the result before returning it from the get_all_items
function, the items are there, but after the copy is constructed in the
caller, it contains garbage.
Any ideas?
|