Bug 16631 – Program crash when a version activates a method defined in a static library

Status
RESOLVED
Resolution
INVALID
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-10-21T06:24:00Z
Last change time
2017-01-24T11:19:00Z
Keywords
safe
Assigned to
nobody
Creator
b2.temp

Attachments

IDFilenameSummaryContent-TypeSize
1621issue16631.zipreproduce the bug (posix)application/zip687

Comments

Comment #0 by b2.temp — 2016-10-21T06:24:34Z
A program crashes when it's linked with a static library and if a version specification is used to activate the protected method of a class. reproduction: === lib.d === module lib; class Foo { protected void bug(){} protected version(bug) void conditionalBug(){} void test() {bug;} } ============= === main.d === module main; import lib; void main() { (new Foo).test; } ============== === test.sh ==== dmd lib.d -lib dmd main.d lib.a -version=bug ./main ================ output: ./test.sh : ligne 3 : 3096 Erreur de segmentation ./main This is caused by the front end because the same error appends with latest stable LDC. Latest stable DMD is affected, latest beta too.
Comment #1 by b2.temp — 2016-10-21T06:27:01Z
Created attachment 1621 reproduce the bug (posix)
Comment #2 by dfj1esp02 — 2016-10-24T08:41:20Z
Works by design. The compiler doesn't know you compiled lib.d with incompatible flags. How would it?
Comment #3 by dfj1esp02 — 2016-10-24T08:56:41Z
Hmm, well, can be considered an accidental breach of safety. There's probably no easy way to fix this. One option can be augmentation of compiled code with metadata that would be checked if linking is done via the compiler.
Comment #4 by b2.temp — 2017-01-24T11:19:00Z
Yes you were right anonymous4. A build system must be used to ensure that the deps are build with right version ident. This report was biased because I've used much some package in another languages that handle this cases. however static libraries are much more simple, a collection of object, directly linkable (i.e not an intermediate format that would keep trace of the version ident). It cant work if the collection is not compiled with the version ident.