Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[x86] segmentation fault with aligned struct parameters #4614

Closed
the-horo opened this issue Apr 2, 2024 · 5 comments
Closed

[x86] segmentation fault with aligned struct parameters #4614

the-horo opened this issue Apr 2, 2024 · 5 comments

Comments

@the-horo
Copy link
Contributor

the-horo commented Apr 2, 2024

I'm not 100% sure if the title is the real cause but the following code crashes:

align(8) struct Cent { }

void udivmod(Cent, int) { }

void main (){
    udivmod(Cent(), 0);
}

It's a reduction from this line in the int128 unittest.

dmd and gdc don't fail. I've only hit this on x86.

@kinke
Copy link
Member

kinke commented Apr 2, 2024

This is a duplicate of #1356; see in particular #1356 (comment).

@kinke kinke closed this as completed Apr 2, 2024
@kinke
Copy link
Member

kinke commented Apr 2, 2024

You do have this existing workaround, right?

version (X86_64) private enum Cent_alignment = 16;
// 32-bit x86: need default alignment due to https://github.com/ldc-developers/ldc/issues/1356
else version (LDC_X86) private enum Cent_alignment = U.alignof;
else private enum Cent_alignment = (size_t.sizeof * 2);

@the-horo
Copy link
Contributor Author

the-horo commented Apr 3, 2024

That's in druntime, I was hitting it in

ldc/dmd/common/int128.d

Lines 23 to 27 in e170ca5

align(16) struct Cent
{
U lo; // low 64 bits
U hi; // high 64 bits
}

which I found out by running ldc2-unittest on x86 when compiling with another ldc2 installation.

@kinke
Copy link
Member

kinke commented Apr 3, 2024

Ah okay, that 'copy'. It's unused, except for ldc2-unittest.

@the-horo
Copy link
Contributor Author

the-horo commented Apr 3, 2024

Alright then, if it's unused and the underlying issue was already reported then I can ignore it. Thank you again for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants