Segmentation fault in DMD - how to debug?

Nicholas Wilson iamthewilsonator at hotmail.com
Wed Sep 28 23:07:34 UTC 2022


On Wednesday, 28 September 2022 at 22:48:47 UTC, Andrey Zherikov 
wrote:
> I'm refactoring my library by mostly moving functions between 
> modules and I get DMD crashes pretty often. The latest example:
> ```
> Program received signal SIGSEGV, Segmentation fault.
> 0x0000555555822ee6 in 
> getTypePointerBitmap::PointerBitmapVisitor::visit(TypeStruct*) 
> ()
>
> (gdb) where
> #0  0x0000555555822ee6 in 
> getTypePointerBitmap::PointerBitmapVisitor::visit(TypeStruct*) 
> ()
> #1  0x0000555555822bc9 in 
> dmd.traits.getTypePointerBitmap(dmd.globals.Loc, 
> dmd.mtype.Type, dmd.root.array.Array!(ulong).Array*) ()
> ```
>
> How do you debug and fix these things?

This seems to stem from use of `__traits(getPointerBitmap, T)`, 
with a `T` that is not handled properly. If you can get a reduced 
test case that will make things much easier. `dustmite` (which 
should come with `dmd`, is useful for automatic reduction, 
otherwise if you have few uses of `__traits(getPointerBitmap, 
T)`, it might be easier to synthesise an example that crashes the 
compiler.



More information about the Digitalmars-d mailing list