Using LD_PRELOAD for a Java executable with Insure++

LegacyForumLegacyForum Posts: 1,664 ✭✭
edited December 2016 in Insure++

I am running insure++ for a java application. Because of the java executable that ignites my application isn't instrumented, i have to add to LD_PRELOAD insure specific libraries in order not to take runtime errors. My LD_PRELOAD looks like this:

The problem is that when i run the application, reports and coverage information is being written for bash shell (!) as well apart from my application. [The bash shell is used to launch the application]. Is it a way in order not to take such information for system specific software?

My runtime .psrc looks like this:

insure++.unsuppress all insure++.leak_search off insure++.use_lockf 10 insure++.report_banner off insure++.coverage_banner off insure++.exit_on_error_banner off insure++.symbol_banner on insure++.symbol_table on insure++.reportfile /var/insure/rpts/%v-%p-insrpt.txt insure++.summarize leaks outstanding insure++.coverage_log_file /var/insure/cov/%v-inscov.log

Moreover this java application sporadically keeps cloning itself only when ran instrumented under insure++.
An instance of such a behavior is the following:

11463 11462 8 08:38 pts/0 00:00:45 java -D -Xrs -Xmx16m -Xss1m
11501 11463 0 08:38 pts/0 00:00:00 java -D -Xrs -Xmx16m -Xss1m

Any clue why this could be happening?

Is it possible that these two problems can be correlated?

Thanks in advance


  • LegacyForumLegacyForum Posts: 1,664 ✭✭

    Seems like 2 issues.

    Setting and unsetting LD_PRELOAD is a system level thing; Insure++ can't really control that. Insure++ does have an option 'runtime off' that effectively turns Insure++ off, but I can't think of a good way to get that option turned on in the child processes you want to ignore. Perhaps LD_PRELOAD could be set or unset in different places? Separating report_files based on %v and %p is what I would have recommended, and just ignoring the bash processes, but it seems you are already doing this.

    As far as the java cloning issue; I am not sure; I do know some versions of java respawm themselves under certain circumstances. I suggest looking at /proc/<java_pids>/environment or something if you want to investigate that further. Again, your best and laziest bet, is to simply ignore the extraneous process and report file.

    If you use _Insure_printf() to print from your instrumented code, then you could simply grep for that string in the report files, and ignore any report files that lacked it.
  • LegacyForumLegacyForum Posts: 1,664 ✭✭
    edited December 2016
    If you do this:
    you have effectively told the shell that you want these libraries pre-loaded for *everything* you do. Don't do that. Instead, just LD_PRELOAD for the one command that you want. Assuming your application that needs to be preloaded is java, (with command line: "java -jar foo.jar"), then the appropriate thing to do is: java -jar foo.jar

    This way, the LD_PRELOAD will only affect the ONE java command, and nothing else.

Sign In or Register to comment.