Skip to content

Commit

Permalink
[transaction] Fix crash after using dnf.comps.CompsQuery and forking …
Browse files Browse the repository at this point in the history
…the process in Anaconda.

dnf.base.Base.install_specs() uses CompsQuery.
CompsQuery opens a connection to the history database.
Anaconda runs do_transaction() as a background (forked) process.
The fork leads to undefined behavior and crash after an attempt
to work with the history database.
  • Loading branch information
Daniel Mach authored and m-blaha committed Aug 10, 2018
1 parent 75475ed commit bc3b61f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion libdnf/transaction/CompsEnvironmentItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,10 @@ CompsEnvironmentItem::getTransactionItemsByPattern(SQLite3Ptr conn, const std::s

std::vector< TransactionItemPtr > result;

SQLite3::Query query(*conn, sql);
// HACK: create a private connection to avoid undefined behavior
// after forking process in Anaconda
SQLite3 privateConn(conn->getPath());
SQLite3::Query query(privateConn, sql);
std::string pattern_sql = pattern;
std::replace(pattern_sql.begin(), pattern_sql.end(), '*', '%');
query.bindv(pattern, pattern, pattern);
Expand Down
5 changes: 4 additions & 1 deletion libdnf/transaction/CompsGroupItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,10 @@ CompsGroupItem::getTransactionItemsByPattern(SQLite3Ptr conn, const std::string

std::vector< TransactionItemPtr > result;

SQLite3::Query query(*conn, sql);
// HACK: create a private connection to avoid undefined behavior
// after forking process in Anaconda
SQLite3 privateConn(conn->getPath());
SQLite3::Query query(privateConn, sql);
std::string pattern_sql = pattern;
std::replace(pattern_sql.begin(), pattern_sql.end(), '*', '%');
query.bindv(pattern, pattern, pattern);
Expand Down

0 comments on commit bc3b61f

Please sign in to comment.