www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11357] New: Weird behavior of appender with File as the element... do not know exactly where the bug resides.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11357

           Summary: Weird behavior of appender with File as the element...
                    do not know exactly where the bug resides.
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody puremagic.com
        ReportedBy: maidenphil hotmail.com



PDT ---
So I just found some weird behavior while using std.array.Appender in
conjunction with std.stdio.File.

The attachment shows it best but, simply put:
auto app = appender!( File[] )();
foreach( i = 0; i < dontMatter; ++i ) {
  app.put( stdout );
}

Crashes. Of course, my real life needs did not include copying stdout, but
rather filling an array with files using the appender.

Phil

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 25 2013
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11357




PDT ---
Version of dmd is 2.063.2

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 25 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11357




PDT ---
Created an attachment (id=1284)
Run this and it crashes

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 25 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11357


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com



Issue is in appender, that doesn't properlly construct objects when inserting
them, it merely assign them.

There is an existing pull that already fixes this:
https://github.com/D-Programming-Language/phobos/pull/1529

That said, putting things with destructors (such as File) is a *terrible* idea,
as things put inside dynamic arrays are never "finalized" (destroyed). So
basically, you'll never close your files.

Prefer using std.container.Array: Not only does this correctly construct your
objects, it will also deterministically manage their lifecycle.

TY for filing the issue.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 25 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11357




PDT ---

 Issue is in appender, that doesn't properlly construct objects when inserting
 them, it merely assign them.
 
 There is an existing pull that already fixes this:
 https://github.com/D-Programming-Language/phobos/pull/1529
 
 That said, putting things with destructors (such as File) is a *terrible* idea,
 as things put inside dynamic arrays are never "finalized" (destroyed). So
 basically, you'll never close your files.
 
 Prefer using std.container.Array: Not only does this correctly construct your
 objects, it will also deterministically manage their lifecycle.
 
 TY for filing the issue.
Good to know regarding the never finalized objects/structs. I am thankful for this information. I will give std.container.Array a try, thank you! Phil -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 25 2013