digitalmars.D.learn - Weird error occurance
- Josh (106/106) Aug 07 2013 I'm having a rather weird error when things that should have no
- Manfred Nowak (6/8) Aug 08 2013 Seems that inserting symbolic debug info is broken in such a way, that i...
- Andrej Mitrovic (4/6) Aug 08 2013 It seems like another case of:
I'm having a rather weird error when things that should have no effect are changed. The purpose of the program is to recursively go through the directories, creating a DirEntry for each file/folder found. The parts in try-catch are there to skip anything that is unreachable. "C:\Users\All Users\Application Data" is the first real problem I've had. This is because on Windows 7, it is a locked shortcut, I presume for XP compatibility. First, the code: import std.algorithm; import std.array; import std.conv; import std.datetime; import std.exception; import std.file; import std.process; import std.stdio; import std.string; void main() { writeln(scanDrive("C:\\Users", true).data.length); } alias Appender!(DirEntry[]) DirEntryAppender; DirEntryAppender scanDrive(string drive, bool saving) { bool b = (drive == "C:\\Users\\All Users\\Application Data"); string[] names; DirEntryAppender entries; try { foreach (d; dirEntries(drive, SpanMode.shallow))//this is the line that causes the error { } } catch (FileException fe) { return DirEntryAppender([]); } foreach (d; dirEntries(drive, SpanMode.shallow)) { names ~= d.name; } if (saving) { DirEntry d = dirEntry(drive); entries.put(d); foreach (n; names) { try { d = dirEntry(n); if (d.isDir && !canFind(d.name, "Windows") && !canFind(d.name, "Program Files") && !canFind(d.name, "ProgramData") && !canFind(d.name, "Josh")) entries.put(scanDrive(n, saving).data); else entries.put(d); } catch (FileException fe) { } } } return entries; } The results are: g si sp b w 0 0 0 0 1 0 0 0 1 1 0 0 1 0 0 0 0 1 1 0 0 1 1 0 0 0 1 1 1 0 1 0 0 0 1 1 0 0 1 1 1 0 1 0 0 1 0 1 1 1 1 1 1 0 0 1 1 1 1 1 g = compiled with -g si = the if (saving) line, 0 means commented out with the contents of the if left uncommented sp = saving is a parameter, 0 means all occurrences commented out, including the if (saving) line b = bool b = ... line, 0 means commented out w = works without error The error that I'm getting is an infinite loop of: object.Error: Access Violation ---------------- 0x0040B426 in void std.typecons.__T10RefCountedTS3std4file15DirIteratorImplVE3std8typecons24RefCountedAutoInitialize0Z.RefCounted.__dtor() ---------------- Bypasses std.file.FileException std\file.d(2311) === Bypassed === std.file.FileException std\file.d(2311): C:\Users\All Users\Application Data: Access is denied. ---------------- 0x0040F842 in bool std.file.cenforce!(bool).cenforce(bool, lazy const(char)[], immutable(char)[], uint) ---------------- Does anybody know why simply creating an unused bool variable, or compiling with -g would make it work? I'm using Windows 7, with DMD v2.062. Any help would be much appreciated. Thanks, Josh
Aug 07 2013
Josh wrote:I'm having a rather weird error when things that should have no effect are changed.Seems that inserting symbolic debug info is broken in such a way, that it touches ram out of its bounds---and the code for comparing the string covers that ram. Commenting out the code and the string allows sensitive code/xdata to enter that poisoned area of ram: a haisen-nug. -manfred
Aug 08 2013
On 8/8/13, Josh <moonburntm gmail.com> wrote:The error that I'm getting is an infinite loop of: object.Error: Access ViolationIt seems like another case of: http://d.puremagic.com/issues/show_bug.cgi?id=6329 I think you should add your test-case there and re-open that issue.
Aug 08 2013