fix Issue 24184 - [REG 2.103] Segmentation fault accessing variable with align(N) > platform stack alignment (#15820)

This commit is contained in:
Walter Bright 2023-11-16 02:46:31 -08:00 committed by GitHub
parent 3d552df287
commit 891cf59b1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 35 additions and 3 deletions

View file

@ -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)

View file

@ -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

View 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(); }