Segmentation error at the end problem

Gide Nwawudu gide at btinternet.com
Wed Jan 28 04:30:46 PST 2009


On Tue, 27 Jan 2009 22:48:33 -0800, Charles Hixson
<charleshixsn at earthlink.net> wrote:

>Main routine:
>
>void	main()
>{
>    try
>    {  BlockFile	bf;
>       bf  =  new BlockFile ("test.bf", 4096);
>       writefln ("before close");
>       bf.close;
>       bf  =  null;
>       writefln ("after close");
>       BlockFile	cf  =  new  BlockFile ("test.bf", 4096);
>       writefln ("after second open");
>    }
>    catch (Exception e)
>    {  writefln ("Caught Exception ", e);  }
>}
>
>Results in:
>Exiting BlockFile::this
>before close
>after close
>Exiting BlockFile::this
>after second open
>Segmentation fault
>
>I could post all the code.  It's only 146 lines.  But perhaps this is 
>enough?

I'm thinking it might be an issue with close and the dtor being called
on the same object. If you add std.gc.fullCollect() after the bf =
null. Does that make the code seg fault before 'after close' is
written? 

Gide


More information about the Digitalmars-d-learn mailing list