Bug 19148 – Alignment of section does not reflect the maximum alignment of its contents

Status
NEW
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2018-08-08T00:46:05Z
Last change time
2024-12-13T19:00:11Z
Assigned to
No Owner
Creator
Yuxuan Shui
Moved to GitHub: dmd#19475 →

Comments

Comment #0 by yshuiv7 — 2018-08-08T00:46:05Z
This cause ldc compiled with dmd to crash, because of an unaligned SIMD instruction.
Comment #1 by yshuiv7 — 2018-08-08T01:23:04Z
Whops, not the problem. But ldc still crashes, looking into it...
Comment #2 by yshuiv7 — 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.
Comment #3 by yshuiv7 — 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.
Comment #4 by dbugz — 2018-08-25T15:25:27Z
Which ldc and DMD versions? Does the just-released LDC 1.11 have this problem?
Comment #5 by yshuiv7 — 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
Comment #6 by dbugz — 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.
Comment #7 by yshuiv7 — 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
Comment #8 by dbugz — 2018-08-26T04:26:27Z
OK, if you're so sure it's a problem in dmd's backend, a pull request is welcome.
Comment #9 by yshuiv7 — 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.
Comment #10 by robert.schadek — 2024-12-13T19:00:11Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19475 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB