digitalmars.D.bugs - Bug in string or AA handling
- =?ISO-8859-1?Q?Jari-Matti_M=E4kel=E4?= (37/37) Mar 31 2006 This code segfaults on linux with dmd 0.150 even with all debug-flags on...
- Walter Bright (3/11) Mar 31 2006 It does look like the AA problem with the key type not being a multiple
- =?ISO-8859-1?Q?Jari-Matti_M=E4kel=E4?= (3/15) Mar 31 2006 Ok, thanks. I knew there was an AA thing already in the bugzilla, but
This code segfaults on linux with dmd 0.150 even with all debug-flags on: import std.string, std.date, std.random; alias char[] String; class Node { String label; Node[char] successors; this(String l) { label = l; } void countCommonPrefix(String str) { int a = str.length, b = label.length, m = a < b ? a : b, c; while (c < m && str[c] == label[c]) c++; } void add(String str) { if (!(str[0] in successors)) successors[str[0]] = new Node(str); successors[str[0]].countCommonPrefix(str); } } void main() { String data; for(int i=0; i<100; i++) data ~= lowercase[rand()%lowercase.length]; real estimate = getUTCtime() + TicksPerSecond*10; while (getUTCtime<estimate) { auto root = new Node("a"); for (int i = 0; i < data.length; ++i) root.add(data[i..$]); } } Any idea, why it does so? If you shorten the time interval or data string length, it may not segfault. This is a "minimal" test case made of the suffix tree algorithm I had previously problems with. Another way to prevent segfaults may (YMMV) be to use this "fix": row 11: - while (c < m && str[c] == label[c]) c++; + while (c < m) if (str[c]==label[c]) c++; I don't understand - &&-expressions should actually work this way. See http://www.digitalmars.com/d/expression.html#AndAndExpression. -- Jari-Matti
Mar 31 2006
Jari-Matti Mäkelä wrote:This code segfaults on linux with dmd 0.150 even with all debug-flags on: import std.string, std.date, std.random; alias char[] String; class Node { String label; Node[char] successors;It does look like the AA problem with the key type not being a multiple size of a pointer size. A fix for this will go out in the next update.
Mar 31 2006
Walter Bright wrote:Jari-Matti Mäkelä wrote:Ok, thanks. I knew there was an AA thing already in the bugzilla, but you never can be too sure :)This code segfaults on linux with dmd 0.150 even with all debug-flags on: import std.string, std.date, std.random; alias char[] String; class Node { String label; Node[char] successors;It does look like the AA problem with the key type not being a multiple size of a pointer size. A fix for this will go out in the next update.
Mar 31 2006