www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24832] New: Segfault in hex string

https://issues.dlang.org/show_bug.cgi?id=24832

          Issue ID: 24832
           Summary: Segfault in hex string
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: alphaglosined gmail.com

Via godbolt I got this stack trace for ldc:

```
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH
or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  ldc2      0x0000566b8b755cd7 llvm::sys::PrintStackTrace(llvm::raw_ostream&,
int) + 39
1  ldc2      0x0000566b8b753acc llvm::sys::RunSignalHandlers() + 188
2  ldc2      0x0000566b8b75637f
3  libc.so.6 0x00007f523f442520
4  ldc2      0x0000566b88398e9a _D3dmd5utils18arrayCastBigEndianFNbxAhmZAh +
362
5  ldc2      0x0000566b8820c2ed
_D3dmd5dcast6castToFCQt10expression10ExpressionPSQBv6dscope5ScopeCQCm5mtype4TypeQpZQCl
+ 4365
6  ldc2      0x0000566b8824ae8d ExpressionSemanticVisitor::visit(CastExp*) +
525
7  ldc2      0x0000566b8820e5ce
_D3dmd7initsem19initializerSemanticFCQBj4init11InitializerPSQCg6dscope5ScopeKCQCy5mtype4TypeEQDnQCe13NeedInterpretZ8visitExpMFCQEvQDm14ExpInitializerZQEk
+ 1806
8  ldc2      0x0000566b8824391c DsymbolSemanticVisitor::visit(VarDeclaration*)
+ 7388
9  ldc2      0x0000566b8822d63e
_D3dmd12statementsem22statementSemanticVisitFCQBs9statement9StatementPSQCr6dscope5ScopeZ8visitExpMFCQDuQCc12ExpStatementZv
+ 366
10 ldc2      0x0000566b88229d37
_D3dmd12statementsem22statementSemanticVisitFCQBs9statement9StatementPSQCr6dscope5ScopeZ5visit14VisitStatementMFQCpZv
+ 167
11 ldc2      0x0000566b88380dfe Semantic3Visitor::visit(FuncDeclaration*) +
9902
12 ldc2      0x0000566b8837e615
SemanticTimeTraceVisitor<Semantic3Visitor*>::visit(FuncDeclaration*) + 53
13 ldc2      0x0000566b88311b2c Semantic3Visitor::visit(Module*) + 204
14 ldc2      0x0000566b882f29f1
SemanticTimeTraceVisitor<Semantic3Visitor*>::visit(Module*) + 49
15 ldc2      0x0000566b88498c1b mars_tryMain(Param&, Array<char const*>&) +
1595
16 ldc2      0x0000566b884fcac0 cppmain() + 9376
17 ldc2      0x0000566b8bc760fd
_D2rt6dmain212_d_run_main2UAAamPUQgZiZ6runAllMFZv + 77
18 ldc2      0x0000566b8bc75ed8 _d_run_main2 + 472
19 ldc2      0x0000566b8bc75ced _d_run_main + 141
20 ldc2      0x0000566b8bab81c8 main + 680
21 libc.so.6 0x00007f523f429d90
22 libc.so.6 0x00007f523f429e40 __libc_start_main + 128
23 ldc2      0x0000566b8850137e _start + 46
Program terminated with signal: SIGILL
Compiler returned: 132
```

Appears the erroring code is dmd.utils : arrayCastBigEndian.

https://github.com/dlang/dmd/blob/master/compiler/src/dmd/utils.d#L240

Failing code:

```d
void main()
{
    static immutable CasingDiced[] ReturnValues =
cast(CasingDiced[])x"FFFFFFFFFFFFFFFFFFFFFFFF";
}

struct CasingDiced {
    ushort lowerOffset, lowerEnd;
    ushort titleOffset, titleEnd;
    ushort upperOffset, upperEnd;
}
```

--
Oct 24