Dear Doxygen developers,

I am faced with a segmentation fault of Doxygen 1.8.8 (as used by Debian
unstable on amd64) when trying to process the following (invalid?)
header:

| /**
|  * @addtogroup foo1 foo2
|  * @{
|  * @addtogroup foo4 foo5
|  * @{
|  * @defgroup foo1 foo3
|  * @}
|  * @}
|  */

While this example looks artificial, it was processed by earlier
versions of Doxygen and the Enlightenment libraries reproduce the same
segmentation fault (see https://bugs.debian.org/762272).

What happens is that stack space is exhausted in a recursion of
recursivelyAddGroupListToTitle. Turns out the recursion alternates
between group foo1 and foo4. Conceptually, I have no clue what cyclic
subgroup membership is supposed to mean. One way to look at this problem
is to argue that Doxygen fails to refuse processing cyclic subgroups.
Alternatively the depth of the recursion can be limited.

I am proposing the attached patch (suitable to "git am") to make Doxygen
error out when faced with cyclic subgroups. Is this patch reasonable for
inclusion upstream and does it fully fix the problem?

I would like to add some minimal fix to the Debian package as Debian
jessie is almost frozen (i.e. a new upstream release of Doxygen cannot
be added to Debian atm).

Thanks for considering

Helmut
From: Helmut Grohne <[email protected]>
Subject: error out on cyclic subgroup relationships
Bug-Debian: https://bugs.debian.org/762272
Last-Modified: 2014-10-31

The following example causes Doxygen to crash:

/**
 * @addtogroup foo1 foo2
 * @{
 * @addtogroup foo4 foo5
 * @{
 * @defgroup foo1 foo3
 * @}
 * @}
 */

The code above causes a cyclic subgroup relationship. Traversing it using
recursivelyAddGroupListToTitle causes an infinite recursion that dies when
stack space runs out. Since cyclic subgroups don't make any sense, reject them
early.

--- a/src/groupdef.cpp
+++ b/src/groupdef.cpp
@@ -1232,6 +1232,13 @@ void addGroupToGroups(Entry *root,GroupDef *subGroup)
     if (!g->groupname.isEmpty() && (gd=Doxygen::groupSDict->find(g->groupname)) &&
 	!gd->containsGroup(subGroup) )
     {
+      if(subGroup->containsGroup(gd))
+      {
+        err("Refusing to add group %s to group %s, since the latter is already a "
+            "subgroup of the former.\n", subGroup->name().data(),
+	     gd->name().data());
+	 exit(1);
+      }
       gd->addGroup(subGroup);
       subGroup->makePartOfGroup(gd);
     }
------------------------------------------------------------------------------
_______________________________________________
Doxygen-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/doxygen-develop

Reply via email to