running java 5/6 with JNI on java 7 gives stack guard warning
Asked Answered
M

2

6

A java program built with 1.5 (or 1.6 with 1.5 comparability mode on) gives this warning:

Java HotSpot(TM) Server VM warning: You have loaded library mynativelib.so which might have disabled stack guard.
The VM will try to fix the stack guard now. It's highly recommended that you fix the library with 'execstack -c ', or link it with '-z noexecstack'.

It doesn't seem to cause a problem but obviously would look a bit scary to our customers. I don't think building the java bits in 7 would fix this issue but I'm struggling to see where the docs say how to build JNI libs for Java 7, which is what the warning implies I should be doing differently.

So where should I be looking?

Marketable answered 19/9, 2013 at 7:55 Comment(1)
This will be an option you build the JNI with. i.e. with gcc or g++ or whatever. You could also try the command suggested, as a part of the build.Raffinate
W
5

Found the answer here disabled stack guard warning (ACF9, JVM 1.7, Linux)

He said

This is a feature in Java 7’s HotSpot compiler on Linux which tries to stop code written in C and linked into Java (the so-called Java Native Interface - JNI) from halting the whole VM if it’s written badly or maliciously.

Winograd answered 4/11, 2013 at 3:13 Comment(1)
The gist of the post is that if it's a warning about a 3rd party library you are accessing through JNI and you have faith it will work smoothly, then it's ok to ignore the warning. If you are able to change the compilation of the library, then you could research how to enable stack guard for the library.Elusive
T
2

Another possibility is that the Java+JNI application that you are trying to run was compiled for Linux 32bit.

In such a case, two solutions:

  • If you have the source code of the application, port it to Linux 64bit
  • If not, download the Linux 64bit version of the application.
Tarshatarshish answered 18/1, 2016 at 3:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.