use LD_PRELOAD with Java VM

ronghuazhang_at_gmail.com
Date: 03/30/05


Date: 29 Mar 2005 21:06:37 -0800

I need to monitor (and potentially change) some system calls made by a
java program. I tried to use LD_PRELOAD to substitute my own version
for the libc system call wrappers. I wrote a braindead mylib.so which
simply prints out the system call name when a system call is made and a
LOAD message when it's loaded. The process id is also printed along
with the messages. A couple of strange things happened when I tested
it.

When I executed LD_PRELOAD=mylib.so java helloWorld, to my surprise,
the LOAD message was printed *twice* with the same process id. How come
the library was loaded twice? But the write system call was correctly
caught.

I then run LD_PRELOAD=mylib.so java echo. The echo program is a
classical echo server. I was expecting the LISTEN and ACCEPT system
call would be intercepted. But neither one of them was caught. The
command "strace java echo" showed that it indeed called listen and
accept.

Anybody can shed some light on these peculiarities? Please cc to me so
that I won't miss your post. Thanks!

Ronghua



Relevant Pages

  • Re: Problem With Crypt::CBC
    ... is later read in by a Java program. ... continue using the passwords and vectors I'm using (both 8 bytes, ... use the hash, then the Java program on the other end will not be able to ...
    (comp.lang.perl.misc)
  • Re: deadlock and thread
    ... i have "main" java program usually called as midlet, ... other java programs which is called by the main program to perform ... several task such as sending and receiving sms etc. ... As near as I can tell, in a MIDlet you have access to the same Thread class available in regular Java apps. ...
    (comp.lang.java.programmer)
  • Re: How to interact with a Live java process from php?
    ... This service can only be accessed from a java program on the backend, and this program, unfortunately, is a 24/7 live process. ... My teammate is going to write a php program to handle the front end request, so my question is that, is it possible for such a design to work? ... I'll guess the "live 24/7" backend java process is a "java servlet" ...
    (comp.lang.php)
  • Re: Problem With Crypt::CBC
    ... My Perl script has to output data that ... is later read in by a Java program. ... use the hash, then the Java program on the other end will not be able to ...
    (comp.lang.perl.misc)
  • Re: How to compare the speed between a Java program and its original Fortran version program?
    ... I have translated an old Fortran program into Java program, ... Coughing up a meager translation of a FORTRAN program to Java, then running meaningless benchmarks to try to figure out if you did anything useful is a huge disservice to your customer. ...
    (comp.lang.java.programmer)