Operating System - HP-UX
1752286 Members
4521 Online
108786 Solutions
New Discussion юеВ

received SIGSEGV while executing an exe

 
Vishal2k5
Occasional Advisor

received SIGSEGV while executing an exe

I am working on HP_UX Itanium 11.31
There, I have created an executable file by compiling it with gcc 4.4.3.
When I am running that binary file error is coming :Segmentation fault (core dumped)

# file core
ELF-32 core file - IA64 from 'iEngine' - received SIGSEGV

Also please let me know how to create 64 bit executable on the same machine using gcc
4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: received SIGSEGV while executing an exe

Have you tried debugging your executable with -g and gdb? It is likely to still fail in 64 bit mode.

Use -mlp64 for 64 bit.
Vishal2k5
Occasional Advisor

Re: received SIGSEGV while executing an exe

Yes I debugged it & debugger output is

Program received signal SIGSEGV, Segmentation fault
si_code: 2 - SEGV_ACCERR - Invalid Permissions for object.
0x9fffffffed949cd0:0 in ENTER_PTHREAD_LIBRARY_FUNC+0x50 ()
from /usr/lib/hpux64/libpthread.so.1
(gdb) where
#0 0x9fffffffed949cd0:0 in ENTER_PTHREAD_LIBRARY_FUNC+0x50 ()
from /usr/lib/hpux64/libpthread.so.1
#1 0x9fffffffed98e920:0 in pthread_num_processors_np+0xa0 ()
from /usr/lib/hpux64/libpthread.so.1
#2 0x9fffffffee9367e0:0 in os::active_processor_count ()
at /CLO/Components/JAVA_HOTSPOT/Src/src/os/hp-ux/vm/os_hp-ux.cpp:842
#3 0x9fffffffeec1b3f0:0 in os::is_server_class_machine ()
at /CLO/Components/JAVA_HOTSPOT/Src/src/share/vm/runtime/os.cpp:845
#4 0x9fffffffeec1ad60:0 in Arguments::set_ergonomics_flags ()
at /CLO/Components/JAVA_HOTSPOT/Src/src/share/vm/runtime/arguments.cpp:1239
#5 0x9fffffffeec0db60:0 in Arguments::parse ()
at /CLO/Components/JAVA_HOTSPOT/Src/src/share/vm/runtime/arguments.cpp:2673
#6 0x9fffffffeec06cc0:0 in Threads::create_vm ()
at /CLO/Components/JAVA_HOTSPOT/Src/src/share/vm/runtime/thread.cpp:3451
#7 0x9fffffffeec048b0:0 in JNI_CreateJavaVM ()
at /CLO/Components/JAVA_HOTSPOT/Src/src/share/vm/prims/jni.cpp:2674
#8 0x4000000000004340:0 in JNI_main (argc=1, argv=0x9ffffffffffff5c0)
at eInvokeJVM.c:493
Vishal2k5
Occasional Advisor

Re: received SIGSEGV while executing an exe

I have tried the sample program but it is also not working at my end
I am working on HP_UX Itanium processor

Sample Code is

#include
#include
#include

/* This is the program's "main" routine. */
int main (int argc, char *argv[]) {

JavaVM *jvm; /* denotes a Java VM */
JNIEnv *env; /* pointer to native method interface */
JavaVMInitArgs vm_args;
JavaVMOption options[1];

jint res;
jclass cls;
jmethodID mid;

/* IMPORTANT: need to specify vm_args version especially if you are not using JDK1.1.
* Otherwise, will the compiler will revert to using the 'JDK1_1InitArgs' struct.
*/
vm_args.version = JNI_VERSION_1_4;

/* This option doesn't do anything, just to illustrate how to pass args to JVM. */
options[0].optionString = "-verbose:none";
vm_args.nOptions = 1;
vm_args.options = options;
vm_args.ignoreUnrecognized = JNI_FALSE;

/* load and initialize a Java VM, return a JNI interface pointer in env */
res = JNI_CreateJavaVM(&jvm,(void**)&env,&vm_args);
if (res < 0) {
fprintf(stderr, "Can't create Java VM\n");
exit(1);
}

jclass ver;
jmethodID print;

ver = (*env)->FindClass(env, "sun/misc/Version");
if (ver == 0) {
fprintf(stderr, "Can't find Version");
}
print = (*env)->GetStaticMethodID(env, ver, "print", "()V");
(*env)->CallStaticVoidMethod(env, ver, print);

/* invoke the Main.test method using the JNI */
cls = (*env)->FindClass(env, "Main");
if (cls == 0) {
fprintf(stderr, "Can't find Main.class\n");
exit(1);
}

mid = (*env)->GetStaticMethodID(env, cls, "test", "(I)V");
if (mid==0) {
fprintf(stderr, "No such method!\n");
exit(1);
}
// otherwise execute this method
(*env)->CallStaticVoidMethod(env, cls, mid,100);

/* We are done. */
(*jvm)->DestroyJavaVM(jvm);

return 0;
}
---------------------------------------------------------------------------------------------------------------------------------------------------

It is successfully compiling & generating an exe
To generate exe following script is used

JAVA_HOME=/opt/java6
LIB_PATH=$JAVA_HOME/jre/lib/IA64W
INCLUDE_PATH=$JAVA_HOME/include

$JAVA_HOME/bin/javac Main.java

#Compile the invoker .c file
~/gcc -g -mlp64 -I$INCLUDE_PATH -I$INCLUDE_PATH/hp-ux -L$LIB_PATH -L$LIB_PATH/server -ljava -ljvm -lverify testJNI.c -o testJNI
---------------------------------------------------------------------------------------------------------------------------------------------------

public class Main
{
public static void main(String[] args)
{
System.out.println("Argument: " + args[0]);
}

public static void test(int arg)
{
System.out.println("Test Argument: " + arg);
}
}
---------------------------------------------------------------------------------------------------------------------------------------------------
export JAVA_HOME=/opt/java6
export LIB_PATH=$JAVA_HOME/jre/lib/IA64W
export LD_LIBRARY_PATH=$LIB_PATH:$LIB_PATH/server
./testJNI
---------------------------------------------------------------------------------------------------------------------------------------------------

following is the debugger output

Program received signal SIGSEGV, Segmentation fault
si_code: 2 - SEGV_ACCERR - Invalid Permissions for object.
0x9fffffffed949cd0:0 in ENTER_PTHREAD_LIBRARY_FUNC+0x50 ()
from /usr/lib/hpux64/libpthread.so.1
(gdb) where
#0 0x9fffffffed949cd0:0 in ENTER_PTHREAD_LIBRARY_FUNC+0x50 ()
from /usr/lib/hpux64/libpthread.so.1
#1 0x9fffffffed98e920:0 in pthread_num_processors_np+0xa0 ()
from /usr/lib/hpux64/libpthread.so.1
#2 0x9fffffffee9367e0:0 in os::active_processor_count ()
at /CLO/Components/JAVA_HOTSPOT/Src/src/os/hp-ux/vm/os_hp-ux.cpp:842
#3 0x9fffffffeec1b3f0:0 in os::is_server_class_machine ()
at /CLO/Components/JAVA_HOTSPOT/Src/src/share/vm/runtime/os.cpp:845
#4 0x9fffffffeec1ad60:0 in Arguments::set_ergonomics_flags ()
at /CLO/Components/JAVA_HOTSPOT/Src/src/share/vm/runtime/arguments.cpp:1239
#5 0x9fffffffeec0db60:0 in Arguments::parse ()
at /CLO/Components/JAVA_HOTSPOT/Src/src/share/vm/runtime/arguments.cpp:2673
#6 0x9fffffffeec06cc0:0 in Threads::create_vm ()
at /CLO/Components/JAVA_HOTSPOT/Src/src/share/vm/runtime/thread.cpp:3451
#7 0x9fffffffeec048b0:0 in JNI_CreateJavaVM ()
at /CLO/Components/JAVA_HOTSPOT/Src/src/share/vm/prims/jni.cpp:2674
#8 0x4000000000000f90:0 in main (argc=1, argv=0x9ffffffffffff660)
at testJNI.c:29
(gdb) list
11 JavaVMOption options[1];
12
13 jint res;
14 jclass cls;
15 jmethodID mid;
16
17 /* IMPORTANT: need to specify vm_args version especially if you are not using JDK1.1.
18 * Otherwise, will the compiler will revert to using the 'JDK1_1InitArgs' struct.
19 */
20 vm_args.version = JNI_VERSION_1_4;

---------------------------------------------------------------------------------------------------------------------------------------------------

Can u pleas help me out in finding the solution
Vishal2k5
Occasional Advisor

Re: received SIGSEGV while executing an exe

ldd testJNI

libjava.so => /opt/java1.5/jre/lib/IA64W/libjava.so
libjvm.so => /opt/java1.5/jre/lib/IA64W/hotspot/libjvm.so
libverify.so => /opt/java1.5/jre/lib/IA64W/libverify.so
libunwind.so.1 => /lib/hpux64/libunwind.so.1
libc.so.1 => /lib/hpux64/libc.so.1
libverify.so => /opt/java1.5/jre/lib/IA64W/./libverify.so
libdl.so.1 => /usr/lib/hpux64/libdl.so.1
libc.so.1 => /usr/lib/hpux64/libc.so.1
libpthread.so.1 => /usr/lib/hpux64/libpthread.so.1
libdl.so.1 => /usr/lib/hpux64/libdl.so.1
libm.so.1 => /usr/lib/hpux64/libm.so.1
librt.so.1 => /usr/lib/hpux64/librt.so.1
libuca.so.1 => /usr/lib/hpux64/libuca.so.1
libunwind.so.1 => /usr/lib/hpux64/libunwind.so.1
libstd_v2.so.1 => /usr/lib/hpux64/libstd_v2.so.1
libcl.so.1 => /usr/lib/hpux64/libcl.so.1
libCsup.so.1 => /usr/lib/hpux64/libCsup.so.1
libuca.so.1 => /usr/lib/hpux64/libuca.so.1
libdl.so.1 => /usr/lib/hpux64/libdl.so.1
libIO77.so.1 => /usr/lib/hpux64/libIO77.so.1
libunwind.so.1 => /usr/lib/hpux64/libunwind.so.1