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

Alignment of section does not reflect the maximum alignment of its contents #19475

Open
dlangBugzillaToGithub opened this issue Aug 8, 2018 · 9 comments
Labels

Comments

@dlangBugzillaToGithub
Copy link

Yuxuan Shui (@yshui) reported this on 2018-08-08T00:46:05Z

Transferred from https://issues.dlang.org/show_bug.cgi?id=19148

Description

This cause ldc compiled with dmd to crash, because of an unaligned SIMD instruction.
@dlangBugzillaToGithub
Copy link
Author

yshuiv7 commented on 2018-08-08T01:23:04Z

Whops, not the problem. But ldc still crashes, looking into it...

@dlangBugzillaToGithub
Copy link
Author

yshuiv7 commented on 2018-08-09T10:14:28Z

Looks like dmd mis-aligned a __gshared variable. .alignof reports an alignment of 16 bytes, while the variable is aligned only to 8 bytes.

@dlangBugzillaToGithub
Copy link
Author

yshuiv7 commented on 2018-08-10T00:39:25Z

I found the actual bug in codegen. In elfobj.c data_start(), when a symbol doesn't have a explicit alignment (Salignment <= 0), the symbol itself is aligned, but its section's alignment is not updated.

To reproduce:

__gshared real x;
pragma(msg, x.alignof);

Compiling it prints: 16LU, but the .data section of the resulting object file is only aligned to 8 bytes.

@dlangBugzillaToGithub
Copy link
Author

dbugz commented on 2018-08-25T15:25:27Z

Which ldc and DMD versions? Does the just-released LDC 1.11 have this problem?

@dlangBugzillaToGithub
Copy link
Author

yshuiv7 commented on 2018-08-25T19:21:19Z

(In reply to Joakim from comment #4)
> Which ldc and DMD versions? Does the just-released LDC 1.11 have this
> problem?

Most recent ldc release fix the build problem. But this is a dmd bug nonetheless.

This bug still exists in dmd master

@dlangBugzillaToGithub
Copy link
Author

dbugz commented on 2018-08-26T04:13:40Z

There was an issue with a ldc header mismatch that kinke found when merging the 2.081 frontend into ldc: are you sure that's not what you're seeing instead?

https://github.com/ldc-developers/ldc/pull/2752#issuecomment-398897813
https://github.com/ldc-developers/ldc/pull/2752#issuecomment-399691107

It's a known bug that DMD 2.081 won't build a working ldc 1.10, have to use 1.11.

@dlangBugzillaToGithub
Copy link
Author

yshuiv7 commented on 2018-08-26T04:18:15Z

(In reply to Joakim from comment #6)
> There was an issue with a ldc header mismatch that kinke found when merging
> the 2.081 frontend into ldc: are you sure that's not what you're seeing
> instead?
> 
> https://github.com/ldc-developers/ldc/pull/2752#issuecomment-398897813
> https://github.com/ldc-developers/ldc/pull/2752#issuecomment-399691107
> 
> It's a known bug that DMD 2.081 won't build a working ldc 1.10, have to use
> 1.11.

I have inspected the generated binary, and found problem in DMD's code. This bug is real. Please read comment #3

@dlangBugzillaToGithub
Copy link
Author

dbugz commented on 2018-08-26T04:26:27Z

OK, if you're so sure it's a problem in dmd's backend, a pull request is welcome.

@dlangBugzillaToGithub
Copy link
Author

yshuiv7 commented on 2018-08-26T18:55:51Z

(In reply to Joakim from comment #8)
> OK, if you're so sure it's a problem in dmd's backend, a pull request is
> welcome.

While I know where the problem is, I don't know what is the proper fix. So I would need some help.

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

No branches or pull requests

1 participant