New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mmfile.d: MmFile destructor changed not to cal enforce #3529
Conversation
Please do not comment out code - we have full history with git anyway, otherwise - LGTM |
Dmitry, what's going on? Looking at the error log, it's not related to the code change at all. |
First of all we need to get you whitelisted. @braddr @MartinNowak |
@DmitryOlshansky Anyone with pull rights can add a user to the white-list here: https://auto-tester.puremagic.com/pulls.ghtml?projectid=1 |
@@ -369,9 +369,13 @@ class MmFile | |||
} | |||
else version (Posix) | |||
{ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just remove this code please. No commented-out outdated code in Phobos ;)
That is documentation tester, not related to this pull. I whitelisted you and a couple of new folks, you should see the results soon. |
@sdegtiarev - cool. One last thing - please squash these 2 commits to one and force-update this branch, thanks! |
commented code removed
done On Tue, 8/11/15, Dmitry Olshansky notifications@github.com wrote: Subject: Re: [phobos] mmfile.d: MmFile destructor changed not to cal enforce (#3529) @sdegtiarev - cool. — |
Fixing bad design of std.mmfile is something to be addressed later. Anyhow I think having this stop-gap fix is good measure for now. |
Auto-merge toggled on |
mmfile.d: MmFile destructor changed not to cal enforce
Dmitry, Can you ask someone to take a look and review? I don't actually know yet how to contribute to std.phobos properly.On Tue, 8/11/15, Dmitry Olshansky notifications@github.com wrote: Subject: Re: [phobos] mmfile.d: MmFile destructor changed not to cal enforce (#3529) Merged #3529. — |
Yes, I believe that new high-level designs are what the doctor ordered.
The concept looks great to me. One thing is that you might to check and forbid pointers via hasIndirections!T. Overall I like it, the name most likely gonig to change as persistence is more general then mmap-ing objects to files. Also - does it work for dynamic arrays? I think it absolutely should special case for Speaking of Phobos inclusion - it's a long road and if you are up to it I can help you with the formal process of adding a new module to phobos. It's a lot of work and takes god-like patience to carry out. Expect no less then 3-4 months of waiting. Are you ready ? ;) |
btw, "doctor ordered" != "доктор прописал" On Thu, 8/13/15, Dmitry Olshansky notifications@github.com wrote: Subject: Re: [phobos] mmfile.d: MmFile destructor changed not to cal enforce (#3529)
Yes, I believe that new high-level designs are what the doctor ordered.
The concept looks great to me. One thing is that you might to check and forbid pointers via hasIndirections!T. Speaking of Phobos inclusion - it's a long road and if you are up to it I can help you with the formal process — |
Great, looking forward to it. The first step would be making it std.experimental.mmap-some-name, opening a pull and starting a discussion on NG. P. S. Now that you say it looked it up. Actually the idiom is "just what the doctor ordered". It might not be word for word for "то что доктор прописал" but has exactly the same meaning. http://idioms.thefreedictionary.com/just+what+the+doctor+ordered |
Great, I'l take a week-two then to tidy it up, there are some subtle points both in interface and impl., and will submit it to experimental.On Fri, 8/14/15, Dmitry Olshansky notifications@github.com wrote: Subject: Re: [phobos] mmfile.d: MmFile destructor changed not to cal enforce (#3529) Are you ready ? ;) Yes I am. I have a lot of patience and I don't rush, seem to be easier, So why not? Great, looking forward to it. The first step would be P. S. Now that you say it looked it up. Actually the http://idioms.thefreedictionary.com/just+what+the+doctor+ordered — |
This fix is incorrect and dangerous. You've removed a potential |
Absolutely. As I said, the right way would be to duplicate the file descriptor. This one was assumed as hot temporary fix. |
Just not to forget, mmfile allows to create zero length file, but throws an exception when unmapping. |
When unmapping? I haven't seen this in the test I wrote: https://github.com/D-Programming-Language/phobos/pull/3619/files#diff-cb622bc0f28338bebabff9a7dd949706R680 |
munmap() is called from destructor, called by GC |
I think that was caused by https://issues.dlang.org/show_bug.cgi?id=14994 Fix: CyberShadow@836be85 |
One more issue:
in short, when file is opened in readOnly mode, it neglects actual file size. Tail bytes are not shared. |
Oops, found something interesting (this is about zero-size file unmapping again)
neither of writeln() statements is ever reached |
Not sure I see the problem. 0-size maps are only supported on OS X 32-bit I think. Please test with #3619 and see if there are any notable problems still ( |
There's a bunch of problems here. Exception thrown from inside GC and class destructor is one of them. As seen from the code, try/catch can't handle it. |
Retested, yes, with the fix everything is smooth. Constructor intercepts mmap() failure and throws. |
@CyberShadow
|
@sdegtiarev I see, can you file that as an issue on Bugzilla? |
@CyberShadow |
Issue 14868:
MmFile(File,Mode,..) constructor caused the underlying file descriptor to be closed twice, in ~File() and ~MmFile(). Since MmFile destructor called enforce to check return status of close() system call, exception was thrown from inside GC.
The .close() call is safe and the only meaningful error is EBADF, when the descriptor is closed already, so I commented out the enforce part.