mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00
fix Issue 24184 - [REG 2.103] Segmentation fault accessing variable with align(N) > platform stack alignment (#15820)
This commit is contained in:
parent
3d552df287
commit
891cf59b1f
3 changed files with 35 additions and 3 deletions
|
@ -609,7 +609,8 @@ elem* toElem(Expression e, ref IRState irs)
|
||||||
soffset = v.offset;
|
soffset = v.offset;
|
||||||
else if (v && v.inAlignSection)
|
else if (v && v.inAlignSection)
|
||||||
{
|
{
|
||||||
ethis = el_bin(OPadd, TYnptr, ethis, el_long(TYnptr, fd.salignSection.Soffset));
|
const vthisOffset = fd.vthis ? -toSymbol(fd.vthis).Soffset : 0;
|
||||||
|
ethis = el_bin(OPadd, TYnptr, ethis, el_long(TYnptr, vthisOffset + fd.salignSection.Soffset));
|
||||||
ethis = el_una(OPind, TYnptr, ethis);
|
ethis = el_una(OPind, TYnptr, ethis);
|
||||||
soffset = v.offset;
|
soffset = v.offset;
|
||||||
}
|
}
|
||||||
|
@ -624,10 +625,10 @@ elem* toElem(Expression e, ref IRState irs)
|
||||||
if (fd.vthis)
|
if (fd.vthis)
|
||||||
{
|
{
|
||||||
Symbol *vs = toSymbol(fd.vthis);
|
Symbol *vs = toSymbol(fd.vthis);
|
||||||
//printf("vs = %s, offset = %x, %p\n", vs.Sident, cast(int)vs.Soffset, vs);
|
//printf("vs = %s, offset = x%x, %p\n", vs.Sident.ptr, cast(int)vs.Soffset, vs);
|
||||||
soffset -= vs.Soffset;
|
soffset -= vs.Soffset;
|
||||||
}
|
}
|
||||||
//printf("\tSoffset = x%x, sthis.Soffset = x%x\n", s.Soffset, irs.sthis.Soffset);
|
//printf("\tSoffset = x%x, sthis.Soffset = x%x\n", cast(uint)s.Soffset, cast(uint)irs.sthis.Soffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nrvo)
|
if (!nrvo)
|
||||||
|
|
|
@ -979,6 +979,7 @@ void buildClosure(FuncDeclaration fd, ref IRState irs)
|
||||||
* Reference:
|
* Reference:
|
||||||
* setClosureVarOffset
|
* setClosureVarOffset
|
||||||
*/
|
*/
|
||||||
|
private
|
||||||
uint setAlignSectionVarOffset(FuncDeclaration fd)
|
uint setAlignSectionVarOffset(FuncDeclaration fd)
|
||||||
{
|
{
|
||||||
// Nothing to do
|
// Nothing to do
|
||||||
|
|
30
compiler/test/runnable/test24184.d
Normal file
30
compiler/test/runnable/test24184.d
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
// https://issues.dlang.org/show_bug.cgi?id=24184
|
||||||
|
|
||||||
|
void stage3(alias abc)(ubyte[])
|
||||||
|
{
|
||||||
|
bool skipSpaces()
|
||||||
|
{
|
||||||
|
abc();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
skipSpaces;
|
||||||
|
}
|
||||||
|
ubyte[] singleThreadJsonImpl(alias xxx)(ubyte[] table)
|
||||||
|
{
|
||||||
|
align(64) ubyte[] vector;
|
||||||
|
|
||||||
|
ubyte[] abc() { return vector; }
|
||||||
|
|
||||||
|
stage3!(abc)(table);
|
||||||
|
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
ubyte[] singleThreadJsonText()
|
||||||
|
{
|
||||||
|
bool xxx() { return true; }
|
||||||
|
|
||||||
|
return singleThreadJsonImpl!(xxx)([]);
|
||||||
|
}
|
||||||
|
void deserializeJson() { singleThreadJsonText(); }
|
||||||
|
|
||||||
|
void main() { deserializeJson(); }
|
Loading…
Add table
Add a link
Reference in a new issue