Understanding SIGSEGV issues

Nicholas Wilson iamthewilsonator at hotmail.com
Sat Jan 5 10:31:39 UTC 2019


On Saturday, 5 January 2019 at 07:34:17 UTC, Russel Winder wrote:
> TransmitterData has a destructor defined but with no code in 
> it. This used to work fine – but I cannot be certain which 
> version of LDC that was.
>
> The problem does seem to be in the construction of the 
> TransmitterData object because a destructor is being called on 
> the File_Ptr field as part of the transmitterData constructor.
>
>> As you can see from the stack trace #3, the File_Ptr is null. 
>> The solution to this is to either ensure it is initialised in 
>> the constructor of TransmitterData, or account for it possibly 
>> being null by defining a destructor for TransmitterData.
>
> For some reason it seems File_Ptr.~this() is being called before
> File_Ptr.this() in the TransmitterData.this(). This is totally 
> weird.
>
> Having added some writeln statements:
>
> (gdb) bt
> #0  0x00005555555932e0 in dvb_file_free (dvb_file=0x0) at 
> dvb_file.d:276
> #1  0x0000555555592fbc in types.File_Ptr.~this() (this=...) at 
> types.d:83
> #2  0x000055555558cdf6 in 
> _D3std6format__T14formattedWriteTSQBg5stdio4File17LockingTextWriterTaTS5types8File_PtrZQCtFKQChxAaQBcZk (w=..., fmt=..., _param_2=...) at /usr/lib/ldc/x86_64-linux-gnu/include/d/std/format.d:472

Maybe it is a problem with copying a File_Ptr (e.g. missing a 
increase of the reference count)? Like, `auto a = File_Ptr(); { 
auto b = a; }` and b calls the destructor on scope exit.
That would be consistent with having problems copying to object 
to pass to writeln.


More information about the Digitalmars-d-learn mailing list