D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7223 - Access violation when using rmdirRecurse on folder without modify permissions
Summary: Access violation when using rmdirRecurse on folder without modify permissions
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-04 13:54 UTC by Jesse Phillips
Modified: 2015-01-27 03:20 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jesse Phillips 2012-01-04 13:54:27 UTC
On Windows if you do not have permissions to modify a folder (i.e. delete it) then the program will crash with an Access Violation instead of throwing a FileException. I tried adding writeln statements to try and narrow down the code and instead I end up with an infinite loop. Interesting bits below.

=== Bypassed ===
std.file.FileException@std\file.d(551): C:\New folder\New Text Document.txt: Acc
ess is denied.
----------------
436098
435F0F
403296
402125
402042
4027C8
40280C
402403
4BF2E5
----------------
object.Error: Access Violation
----------------
436098
435F0F
402042
4027C8
40280C
402403
4BF2E5
----------------
Bypasses std.file.FileException@std\file.d(551)
object.Error: Access Violation
Comment 1 SomeDude 2012-04-19 12:55:44 UTC
Code example ? Link to discussion ?
Comment 2 Jesse Phillips 2012-04-20 08:23:35 UTC
(In reply to comment #1)
> Code example ? Link to discussion ?

A code example is tricky because the issue revolves around the environment and not the specific code. But here you go:

import std.file;

void main() {
    rmdirRecurse(r"C:\noper");
}

Now create C:\noper as a different user from what you will be running it as, or find another way to remove your permissions. Probably throw in a file or two too.
Comment 3 AndyC 2015-01-27 03:20:17 UTC
I used this test code on windows x64 (and linux x64), using dmd 2.066.1:

import std.file, std.stdio;

void main()
{
    try
    {
        rmdirRecurse("/tmp/foo");
    }
    catch (Exception e)
    {
        writeln("Got the exception");
    }
}


I "Got the exception" in both cases.

Tough to say when this was fixed.