Bug 19778 - diff_has_ancestor_filtered_out() loops forever

It appears that there can be cycles in the path made of ancestors.  In
that case, diff_has_ancestors_filtered_out() just loops forever.
Oops.

This patch addresses that issue by making
diff_has_ancestors_filtered_out() detect cycles.

	* src/abg-comparison.cc (diff_has_ancestor_filtered_out): Add an
	overload that takes an additional map of pointer values.  Make the
	older overload call the new one.
	* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm: New test material.
	* tests/data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt:
	New reference output.
	* tests/data/test-diff-pkg/libICE-1.0.9-2.el7.x86_64.rpm: New test material.
	* tests/data/test-diff-pkg/libICE-debuginfo-1.0.6-1.el6.x86_64.rpm: New test material.
	* tests/data/test-diff-pkg/libICE-debuginfo-1.0.9-2.el7.x86_64.rpm:
	New test material.
	* tests/data/Makefile.am: Add the new test material to source distribution.
	* tests/test-diff-pkg.cc (in_out_specs): Run this test harness
	over the new tests material above.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2016-03-07 12:09:12 +01:00
parent ba1b9916ac
commit 3cf729c3ee
8 changed files with 268 additions and 6 deletions

View File

@ -429,6 +429,41 @@ static bool
is_child_node_of_base_diff(const diff* diff)
{return diff && is_base_diff(diff->parent_node());}
/// Test if the current diff node has an ancestor node that has been
/// filtered out.
///
/// This function detects cycles when walking through the "parent"
/// path.
///
/// @param diff the diff node to take into account.
///
/// @param ancestor this is a hash map of the pointers of the parents
/// that are visited. It's used to detect cycles while visiting
/// parents of this diff tree node.
///
/// @return true iff the current diff node has an ancestor node that
/// has been filtered out.
static bool
diff_has_ancestor_filtered_out(const diff* d,
unordered_map<size_t, bool>& ancestors)
{
if (!d || !d->parent_node())
return false;
if (d->parent_node()->is_filtered_out())
return true;
const diff* parent = d->parent_node();
unordered_map<size_t, bool>::const_iterator i =
ancestors.find(reinterpret_cast<size_t>(parent));
if (i != ancestors.end())
// We've just detected a cycle in the path made of the parents
// that we are visiting.
return false;
ancestors[reinterpret_cast<size_t>(parent)] = true;
return diff_has_ancestor_filtered_out(parent, ancestors);
}
/// Test if the current diff node has an ancestor node that has been
/// filtered out.
///
@ -439,11 +474,8 @@ is_child_node_of_base_diff(const diff* diff)
static bool
diff_has_ancestor_filtered_out(const diff* diff)
{
if (!diff || !diff->parent_node())
return false;
if (diff->parent_node()->is_filtered_out())
return true;
return diff_has_ancestor_filtered_out(diff->parent_node());
unordered_map<size_t, bool> ancestors_trace;
return diff_has_ancestor_filtered_out(diff, ancestors_trace);
}
/// The default traverse function.

View File

@ -1048,4 +1048,10 @@ test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64.rpm \
test-diff-pkg/tbb-4.3-3.20141204.fc23.x86_64.rpm \
test-diff-pkg/tbb-debuginfo-4.1-9.20130314.fc22.x86_64.rpm \
test-diff-pkg/tbb-debuginfo-4.3-3.20141204.fc23.x86_64.rpm \
test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt
test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt \
test-diff-pkg/libICE-debuginfo-1.0.6-1.el6.x86_64.rpm \
test-diff-pkg/libICE-debuginfo-1.0.9-2.el7.x86_64.rpm \
test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm \
test-diff-pkg/libICE-1.0.9-2.el7.x86_64.rpm \
libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt

Binary file not shown.

View File

@ -0,0 +1,214 @@
================ changes of 'libICE.so.6.3.0'===============
Functions changes summary: 0 Removed, 23 Changed (78 filtered out), 3 Added functions
Variables changes summary: 1 Removed, 1 Changed (13 filtered out), 0 Added variables
3 Added functions:
'function int _IceTransIsListening(const char*)' {_IceTransIsListening}
'function int _IceTransListen(const char*)' {_IceTransListen}
'function int _IceTransReceived(const char*)' {_IceTransReceived}
23 functions with some indirect sub-type change:
[C]'function IceConn IceAcceptConnection(IceListenObj, IceAcceptStatus*)' at accept.c:38:1 has some indirect sub-type changes:
return type changed:
underlying type '_IceConn*' changed:
in pointed to type 'struct _IceConn' at ICEconn.h:131:1:
2 data member changes (2 filtered):
type of 'IceListenObj _IceConn::listen_obj' changed:
underlying type '_IceListenObj*' changed:
in pointed to type 'struct _IceListenObj' at ICElibint.h:120:1:
1 data member change:
type of '_XtransConnInfo* _IceListenObj::trans_conn' changed:
in pointed to type 'struct _XtransConnInfo' at Xtransint.h:136:1:
type size changed from 640 to 768 bits
2 data member insertions:
'_XtransConnFd* _XtransConnInfo::recv_fds', at offset 640 (in bits) at Xtransint.h:148:1
'_XtransConnFd* _XtransConnInfo::send_fds', at offset 704 (in bits) at Xtransint.h:149:1
1 data member change:
type of '_Xtransport* _XtransConnInfo::transptr' changed:
in pointed to type 'struct _Xtransport' at Xtransint.h:158:1:
1 data member changes (18 filtered):
type of 'int (typedef XtransConnInfo, char*, char*)* _Xtransport::Connect' changed:
in pointed to type 'function type int (typedef XtransConnInfo, char*, char*)':
parameter 2 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
type of '_IcePingWait* _IceConn::ping_waits' changed:
in pointed to type 'typedef _IcePingWait' at ICEconn.h:48:1:
underlying type 'struct _IcePingWait' at ICEconn.h:44:1 changed:
1 data member changes (1 filtered):
type of 'IcePingReplyProc _IcePingWait::ping_reply_proc' changed:
underlying type 'void (typedef IceConn, typedef IcePointer)*' changed:
in pointed to type 'function type void (typedef IceConn, typedef IcePointer)':
parameter 1 of type 'typedef IceConn' has sub-type changes:
underlying type '_IceConn*' changed:
pointed to type 'struct _IceConn' changed; details are being reported
[C]'function int IceLockAuthFile(char*, int, int, long int)' at authutil.c:131:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function int IceRegisterForProtocolReply(char*, char*, char*, int, IcePaVersionRec*, int, const char**, IcePaAuthProc*, IceHostBasedAuthProc, IceProtocolSetupProc, IceProtocolActivateProc, IceIOErrorProc)' at register.c:127:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
parameter 2 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
parameter 3 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function int IceRegisterForProtocolSetup(char*, char*, char*, int, IcePoVersionRec*, int, const char**, IcePoAuthProc*, IceIOErrorProc)' at register.c:36:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
parameter 2 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
parameter 3 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function void IceUnlockAuthFile(char*)' at authutil.c:205:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function void _IceErrorAuthenticationFailed(IceConn, int, char*)' at error.c:225:1 has some indirect sub-type changes:
parameter 3 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function void _IceErrorAuthenticationRejected(IceConn, int, char*)' at error.c:196:1 has some indirect sub-type changes:
parameter 3 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function void _IceErrorProtocolDuplicate(IceConn, char*)' at error.c:254:1 has some indirect sub-type changes:
parameter 2 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function void _IceErrorSetupFailed(IceConn, int, char*)' at error.c:165:1 has some indirect sub-type changes:
parameter 3 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function void _IceErrorUnknownProtocol(IceConn, char*)' at error.c:302:1 has some indirect sub-type changes:
parameter 2 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function void _IceGetPaAuthData(char*, char*, char*, short unsigned int*, char**)' at getauth.c:88:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
parameter 2 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
parameter 3 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function void _IceGetPaValidAuthIndices(char*, char*, int, char**, int*, int*)' at getauth.c:186:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
parameter 2 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function void _IceGetPoAuthData(char*, char*, char*, short unsigned int*, char**)' at getauth.c:57:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
parameter 2 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
parameter 3 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function void _IceGetPoValidAuthIndices(char*, char*, int, char**, int*, int*)' at getauth.c:127:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
parameter 2 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
parameter 4 of type 'char**' changed:
in pointed to type 'char*':
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function int _IceTransConnect(XtransConnInfo, char*)' at Xtrans.c:880:1 has some indirect sub-type changes:
parameter 2 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function int _IceTransCreateListener(XtransConnInfo, char*, unsigned int)' at Xtrans.c:746:1 has some indirect sub-type changes:
parameter 2 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function int _IceTransMakeAllCLTSServerListeners(char*, int*, int*, XtransConnInfo**)' at Xtrans.c:1311:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function int _IceTransMakeAllCOTSServerListeners(char*, int*, int*, XtransConnInfo**)' at Xtrans.c:1180:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function int _IceTransNoListen(char*)' at Xtrans.c:781:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function XtransConnInfo _IceTransOpenCLTSClient(char*)' at Xtrans.c:593:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function XtransConnInfo _IceTransOpenCLTSServer(char*)' at Xtrans.c:606:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function XtransConnInfo _IceTransOpenCOTSClient(char*)' at Xtrans.c:567:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
[C]'function XtransConnInfo _IceTransOpenCOTSServer(char*)' at Xtrans.c:580:1 has some indirect sub-type changes:
parameter 1 of type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
1 Removed variable:
'const in6_addr in6addr_any' {in6addr_any}
1 Changed variable:
[C]'char* _IceAuthNames[1]' was changed to 'const char* _IceAuthNames[1]' at globals.h:37:1:
type of variable changed:
array element type 'char*' changed:
in pointed to type 'char':
entity changed from 'char' to 'const char'
type name changed from 'char*[1]' to 'const char*[1]'
================ end of changes of 'libICE.so.6.3.0'===============

Binary file not shown.

View File

@ -283,6 +283,16 @@ static InOutSpec in_out_specs[] =
"data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt",
"output/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt"
},
{
"data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm",
"data/test-diff-pkg/libICE-1.0.9-2.el7.x86_64.rpm",
"",
"",
"data/test-diff-pkg/libICE-debuginfo-1.0.6-1.el6.x86_64.rpm",
"data/test-diff-pkg/libICE-debuginfo-1.0.9-2.el7.x86_64.rpm",
"data/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt",
"output/test-diff-pkg/libICE-1.0.6-1.el6.x86_64.rpm--libICE-1.0.9-2.el7.x86_64.rpm-report-0.txt"
},
#endif //WITH_RPM
#ifdef WITH_DEB