Linux prelink breaks DMD and GDC executables.

Dave Dave_member at pathlink.com
Fri Apr 7 21:45:26 PDT 2006


Dave wrote:
> kris wrote:
>> Dave wrote:
>>>
>>> prelink (http://www.die.net/doc/linux/man/man8/prelink.8.html) screws 
>>> up some D executables built by DMD or GDC v0.17, which is a 
>>> potentially large problem because it is installed to run 
>>> automatically by default on a lot of Linux systems (for most common 
>>> system bin directories) from what I gather.
>>>
>>> I've seen odd problems apparently caused by prelink on C++ 
>>> executables too (that's what prompted me to try it w/ D exe's), so 
>>> the wisdom of having prelink run by default seems dubious at best. 
>>> It's purely cause-and-effect for me because I haven't the time to dig 
>>> into exactly what is happening to cause the problems.
>>>
>>> On Fedora systems a driver script is setup in /etc/cron.daily.
>>>
>>> I've been able to prevent the prelink by using the -L-pie switch 
>>> (http://www.linuxfromscratch.org/hlfs/view/unstable/uclibc/chapter02/pie.html) 
>>>
>>>
>>> However, I'm not real familiar with exactly what the consequences of 
>>> -pie will be so I'm not recommending it, just putting this info. out 
>>> there in the hopes that someone can explain the problem and work 
>>> toward a fix.
>>>
>>> Obviously, this could have big consequences as more and more D 
>>> executables make their way out into the wild in system bin directories.
>>>
>>> Anyone?
>>
>> What actually happens to the executable ~ does it just die? Worse?
> 
> Some exe's segfault under some conditions, some don't. All I can say so 
> far, but there is a direct cause-and-effect: compile and run it, and the 
> exe works fine all day long, prelink the same executable and it crashes.
> 
> Here's some code:
> 
> import std.stdio, std.string, std.outbuffer;
> 
> int main(char[][] args)
> {
>     int n = args.length > 1 ? atoi(args[1]) : 1;
> 
>     OutBuffer ob = new OutBuffer();
> 
>     for(int i = 0; i < n; i++)
>     {
>         ob.write("hello\n");
>     }
> 
>     writefln(ob.toString().length);
> 
>     return 0;
> }
> 
> # dmd -O -inline -release strcat.d
> # ll strcat
> # for x in `seq 1 10`; do strcat 1000000; done
> # /usr/sbin/prelink ./strcat
> # ll strcat
> # for x in `seq 1 10`; do strcat 1000000; done
> 
> Note that running a prelinked strcat with 10_000 doesn't segfault.
> 
> Compiling phobos with -g -release says it crashes in std/outbuffer.d:92. 
> Run with just -g and it crashes at internal/invariant.d:16. Something in 
> the exe is getting hosed-up.
> 
> I ran into some other D executables a while back that did the same 
> thing, but I can't remember what the issue was - just that it had 
> nothing to do with OutBuffer in those cases.

Just to be clear - I ran into those problems a while back only when the 
exe's were prelink'd, otherwise they ran like a champ.

> 
> - Dave



More information about the Digitalmars-d mailing list