Understanding SIGSEGV issues

Russel Winder russel at winder.org.uk
Wed Jan 9 16:39:28 UTC 2019


On Tue, 2019-01-08 at 09:59 -0500, Steven Schveighoffer via Digitalmars-d-
learn wrote:
> 
[…]
> 
> Russel, make sure your destructor both checks whether the underlying 
> resource is set, and clears it to invalid when freeing it.
> 
> Even types that can't be copied can be moved, or temporarily created as 
> rvalues. When they are moved the shell they get moved out of is still 
> destructed! So it has to have a state where it can be destroyed, even 
> though there is no resource.

I have added tests in the destructor but given the constructor should throw an
exception on a failure to initialise the internal state correctly, it really
ought to be unnecessary. but I guess it cant hurt being there!

As I noted to Nicholas it seems the application is getting a valid data
structure returned with invalid data and that is where the SIGSEGV is. This is
really weird as I have just finished a Rust version of the same application
and it works fine. And this D version used to work fine. It is a real mystery
why there is a problem now.

Sadly the D plugin to CLion doesn't as yet have the same functionality as the
Rust plugin.  Debugging these sorts of thing is just so much better in CLion
than trying to work GDB manually.

> Maybe some inspiration here: 
> https://github.com/MartinNowak/io/blob/master/src/std/io/file.d#L189-L196
> 

I will check that out, thanks for the pointer.

-- 
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20190109/e1c36fba/attachment.sig>


More information about the Digitalmars-d-learn mailing list