Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 3 Jun 2009 16:38:43 -0500
From:      "Deshmukh, Pramod" <Pramod_Deshmukh@securecomputing.com>
To:        <freebsd-java@FreeBSD.org>
Subject:   Error while using strcat() in JNI
Message-ID:  <5CF2BB5045ED7D44B69F3E63642D693207E63FCF@ICE.scur.com>

next in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
Below is the c program which is called by java. Java passed string object to
this method which is converted to char *. When I print using printf()
function it prints the string (char *), but strcat() does not like char *.

 

Attached is the .h file the same. Please help me. Also I have attached the
.log file

 

Thanks in Advance.

 

--Pramod

 

==================================================================

#include "nativetest.h" /*double quotes tells it to search current
directory*/

#include <string.h>

 

JNIEXPORT jstring JNICALL Java_nativetest_sayHello

  (JNIEnv *env, jobject thisobject, jstring p_data, jstring p_salt)

 

{

                printf("Inside C program \n");

                printf("=================================\n");

 

                char *cmdOpenSsl;

                jboolean iscopy;

 

                char* cDesc = strdup((*env)->GetStringUTFChars(env, p_data,
&iscopy));

                printf("cDesc ==  %s ", cDesc);

 

                cmdOpenSsl = "echo -n ";

                strcat(cmdOpenSsl, cDesc);

                printf("cmdOpenSsl == %s", cmdOpenSsl);

 

                return p_data;

}

 

-=====================================================

 

Error is

 

cDesc ==  Pramod

#

# An unexpected error has been detected by HotSpot Virtual Machine:

#

#  SIGBUS (0xa) at pc=0x2814bf62, pid=85946, tid=0x8054000

#

# Java VM: Java HotSpot(TM) Server VM (diablo-1.5.0_07-b01 mixed mode)

# Problematic frame:

# C  [libc.so.6+0xa5f62]  strcat+0x1a

#

# An error report file with more information is saved as hs_err_pid85946.log

#

# If you would like to submit a bug report, please write

# a letter to freebsd-java@FreeBSD.org mailing list

#

Abort trap: 6 (core dumped)

 

 


[-- Attachment #2 --]
/* DO NOT EDIT THIS FILE - it is machine generated */
#include "jni.h"
/* Header for class nativetest */

#ifndef _Included_nativetest
#define _Included_nativetest
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     nativetest
 * Method:    sayHello
 * Signature: (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_nativetest_sayHello
  (JNIEnv *, jobject, jstring, jstring);

#ifdef __cplusplus
}
#endif
#endif

[-- Attachment #3 --]
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
#  SIGBUS (0xa) at pc=0x2814bf62, pid=85946, tid=0x8054000
#
# Java VM: Java HotSpot(TM) Server VM (diablo-1.5.0_07-b01 mixed mode)
# Problematic frame:
# C  [libc.so.6+0xa5f62]  strcat+0x1a
#

---------------  T H R E A D  ---------------

Current thread (0x0805a800):  JavaThread "main" [_thread_in_native, id=134561792]

siginfo:si_signo=10, si_errno=0, si_code=12, si_addr=0x4ffe8979

Registers:
EAX=0x00000050, EBX=0x2ea63668, ECX=0x4ffe8979, EDX=0x08055fb0
ESP=0xbfbfc904, EBP=0xbfbfc9c8, ESI=0x2ea63668, EDI=0x4ffe897a
EIP=0x2814bf62, EFLAGS=0x00010246

Top of Stack: (sp=0xbfbfc904)
0xbfbfc904:   4ffe8971 0805a800 4ffe881f 4ffe8971
0xbfbfc914:   08055fb0 bfbfc937 00000000 00000000
0xbfbfc924:   28718e4c 08055fb0 08055f90 08055f80
0xbfbfc934:   01000000 08053780 4ffe8971 bfbfc960
0xbfbfc944:   2870e476 0805d818 0805d814 bfbfca0c
0xbfbfc954:   288b4088 00000000 0805d814 bfbfc9c0
0xbfbfc964:   28557f1a 0805d814 bfbfc980 0805a800
0xbfbfc974:   00000000 bfbfca34 bfbfca34 00000000 

Instructions: (pc=0x2814bf62)
0x2814bf52:   fc 31 c0 b9 ff ff ff ff f2 ae 8d 4f ff 90 8a 02
0x2814bf62:   88 01 84 c0 74 4c 8a 42 01 88 41 01 84 c0 74 42 

Stack: [0xbfbc0000,0xbfc00000),  sp=0xbfbfc904,  free space=242k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [libc.so.6+0xa5f62]  strcat+0x1a
j  nativetest.sayHello(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;+0
j  nativetest.main([Ljava/lang/String;)V+23
v  ~StubRoutines::call_stub
V  [libjvm.so+0x3cbb48]
V  [libjvm.so+0x59bc58]
V  [libjvm.so+0x3cbc5f]
V  [libjvm.so+0x3d7821]
V  [libjvm.so+0x3e8ce0]
C  [java+0x3b60]  _init+0x2c70
C  [java+0x135a]  _init+0x46a

Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j  nativetest.sayHello(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;+0
j  nativetest.main([Ljava/lang/String;)V+23
v  ~StubRoutines::call_stub

---------------  P R O C E S S  ---------------

Java Threads: ( => current thread )
  0x08189a00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=135894784]
  0x08189800 JavaThread "CompilerThread1" daemon [_thread_blocked, id=135894272]
  0x08189600 JavaThread "CompilerThread0" daemon [_thread_blocked, id=135893504]
  0x08189400 JavaThread "AdapterThread" daemon [_thread_blocked, id=135819008]
  0x08189200 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=135818240]
  0x08189000 JavaThread "Finalizer" daemon [_thread_blocked, id=135816704]
  0x0805ae00 JavaThread "Reference Handler" daemon [_thread_blocked, id=135815936]
=>0x0805a800 JavaThread "main" [_thread_in_native, id=134561792]

Other Threads:
  0x0811b900 VMThread [id=135379456]
  0x08054800 WatcherThread [id=135895296]

VM state:not at safepoint (normal execution)

VM Mutex/Monitor currently owned by a thread: None

Heap
 PSYoungGen      total 3584K, used 146K [0x4c900000, 0x4cd00000, 0x4fd00000)
  eden space 3072K, 4% used [0x4c900000,0x4c924bf8,0x4cc00000)
  from space 512K, 0% used [0x4cc80000,0x4cc80000,0x4cd00000)
  to   space 512K, 0% used [0x4cc00000,0x4cc00000,0x4cc80000)
 PSOldGen        total 26624K, used 0K [0x32900000, 0x34300000, 0x4c900000)
  object space 26624K, 0% used [0x32900000,0x32900000,0x34300000)
 PSPermGen       total 16384K, used 1422K [0x2e900000, 0x2f900000, 0x32900000)
  object space 16384K, 8% used [0x2e900000,0x2ea63b38,0x2f900000)

Dynamic libraries:
0x08048000 	java
0x28083000 	/lib/libz.so.3
0x28094000 	/usr/lib/libthr.so.2
0x280a6000 	/lib/libc.so.6
0x28195000 	/usr/home/pdeshmuk/ctsrc/672/ct/bastion/apps/java/jre/lib/i386/server/libjvm.so
0x288d5000 	/lib/libm.so.4
0x288ec000 	/usr/home/pdeshmuk/ctsrc/672/ct/bastion/apps/java/jre/lib/i386/native_threads/libhpi.so
0x288fd000 	/usr/home/pdeshmuk/ctsrc/672/ct/bastion/apps/java/jre/lib/i386/libverify.so
0x2890a000 	/usr/home/pdeshmuk/ctsrc/672/ct/bastion/apps/java/jre/lib/i386/libjava.so
0x28929000 	/usr/home/pdeshmuk/ctsrc/672/ct/bastion/apps/java/jre/lib/i386/libzip.so
0x4ffe8000 	/usr/home/pdeshmuk/ctsrc/tmp/libnativetest.so
0x28052000 	/libexec/ld-elf.so.1

VM Arguments:
java_command: nativetest
Launcher Type: SUN_STANDARD

Environment Variables:
JAVA_HOME=/ct/apps/java
CLASSPATH=:/ct/apps/java/jre/lib/rt.jar:.
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin:/home/pdeshmuk/bin:/ct/apps/java/bin/:/usr/bin/:/ct/apps/java/include:/ct/apps/java/include/freebsd
LD_LIBRARY_PATH=/usr/home/pdeshmuk/ctsrc/672/ct/bastion/apps/java/jre/lib/i386/server:/usr/home/pdeshmuk/ctsrc/672/ct/bastion/apps/java/jre/lib/i386:/usr/home/pdeshmuk/ctsrc/672/ct/bastion/apps/java/jre/../lib/i386:/ct/lib:/ct/apps/mysql/lib/mysql:/ct/apps/python/lib:/ct/apps/openssl/lib:/ct/apps/snmp/lib:/ct/apps/mcafee/lib:/ct/apps/sophos/lib:/ct/apps/commandav/lib:/ct/apps/libiconv/lib:/ct/apps/ct-imagelib/lib:/ct/apps/libtcnative/lib:/ct/apps/rrdtool/lib:/ct/apps/sclog/lib:/ct/apps/sqlite/lib:/ct/apps/libdkim/lib:/home/pdeshmuk/ctsrc/tmp:/ct/apps/java/include/:/ct/apps/java/include/freebsd/
SHELL=/usr/local/bin/bash

Signal Handlers:
SIGSEGV: [libjvm.so+0x678090], sa_mask[0]=0xfffefeff, sa_flags=0x00000002
SIGBUS: [libjvm.so+0x678090], sa_mask[0]=0xfffefeff, sa_flags=0x00000002
SIGFPE: [libjvm.so+0x59bc60], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGPIPE: [libjvm.so+0x59bc60], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGILL: [libjvm.so+0x59bc60], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGUSR1: [libjvm.so+0x59bd30], sa_mask[0]=0x00000000, sa_flags=0x00000040
SIGUSR2: [libjvm.so+0x59bc60], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
SIGHUP: [libjvm.so+0x59a4c0], sa_mask[0]=0xfffefeff, sa_flags=0x00000002
SIGINT: [libjvm.so+0x59a4c0], sa_mask[0]=0xfffefeff, sa_flags=0x00000002
SIGQUIT: [libjvm.so+0x59a4c0], sa_mask[0]=0xfffefeff, sa_flags=0x00000002
SIGTERM: [libjvm.so+0x59a4c0], sa_mask[0]=0xfffefeff, sa_flags=0x00000002


---------------  S Y S T E M  ---------------

OS:FreeBSD
uname:FreeBSD 6.2-RELEASE FreeBSD 6.2-RELEASE #1: Tue Jul 22 20:14:19 EDT 2008     root@ct62bld.securecomputing.com:/usr/obj/usr/src/sys/DUAL i386
rlimit: STACK 65536k, CORE infinity, NOFILE 65536
CPU:total 4 family 6, cmov, cx8, fxsr, mmx, ht

Memory: 4k page, physical 1909600k

vm_info: Java HotSpot(TM) Server VM (diablo-1.5.0_07-b01) for freebsd-x86, built on Sep 24 2006 16:09:01 by root with gcc 3.4.4 [FreeBSD] 20050518


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5CF2BB5045ED7D44B69F3E63642D693207E63FCF>