[Darshan-users] LD_PRELOAD system() call

Phil Carns carns at mcs.anl.gov
Wed Apr 29 16:13:54 CDT 2015


On 04/29/2015 02:54 PM, Phil Carns wrote:
> On 04/29/2015 12:17 PM, Cristian Simarro wrote:
>> Hello,
>>
>> We have been facing some problems with system() call inside some 
>> C/Fortran codes in our Cray machine.
>>
>> The method used here is compile dynamically and then use LD_PRELOAD. 
>> When the code calls system(command), it hangs the execution if 
>> preloaded with Darshan because it is trying to instrument an internal 
>> system read() with no initialization.
>>
>> The solution we have designed is to unset LD_PRELOAD (if set before) 
>> in the darshan_mpi_initialize function.
>>
>> Has anybody found a similar problem with LD_PRELOAD + system() calls?
> Hi Cristian,
>
> I don't think I've seen this exact combination before, but it seems 
> like something we should be able to reproduce and isolate.
>
> If I understand correctly, it sounds like the underlying process 
> spawned by system() is inheriting the LD_PRELOAD environment variable 
> from the parent program, and it is the underlying process that is 
> getting hung?  If so, does it matter what you run in the system() call 
> or does it seem like pretty anything triggers it?
>
> thanks,
> -Phil

The solution you have suggested (unsetting LD_PRELOAD grammatically 
during Darshan initialization) might not be a bad long term solution, 
maybe with some extra safety logic to make sure we don't accidentally 
unset unrelated LD_PRELOAD entries.  I imagine that once the application 
has gotten to darshan initialization, then the loader has already 
processed the LD_PRELOAD environment variable and we don't need to keep 
it set any longer.  That would help keep it from interfering with child 
processes.

We would definitely need to do some testing to confirm, though.

thanks,
-Phil


More information about the Darshan-users mailing list