Sunday, March 02, 2008

Small Patch for bddbddb

Here's a small bug for bddbddb. If there is a small sized domain (e.g., only 2 functions in the Domain F), and some constant strings in a Datalog file (e.g., 4 additional function names used in the rules), the resulting size of the domain will be out of range (e.g., the size of F is 6 rather than 2, which requires a different bit size) and an exception is raised (e.g., Exception in thread "main" net.sf.javabdd.BDDException: 6 is out of range).

Usually this doesn't hurt because the size of a domain is large enough and it's unlikely to cross the boundary of the BDD size. Though it would fail to compute a call graph for a simple hello-world program.

A possible patch for the method namedConstant in net/sf/bddbddb/Domain.java.
Index: Domain.java
===================================================================
--- Domain.java (revision 654)
+++ Domain.java (working copy)
@@ -114,6 +114,8 @@
if (false && map == null) throw new
IllegalArgumentException("No constant map for Domain " + name + " in
which to look up constant " + constant);
if (map == null) map = new IndexMap(name);
if (!map.contains(constant)) System.err.println("Warning:
Constant " + constant + " not found in map for relation " + name);
- return map.get(constant);
+ int index = map.get(constant);
+ size = BigInteger.valueOf(index + 1L).max(size);
+ return index;
}
}

No comments: