From owner-freebsd-bugs Fri Jun 18 16:40: 8 1999 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 7FC1A1529B for ; Fri, 18 Jun 1999 16:40:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id QAA35675; Fri, 18 Jun 1999 16:40:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: by hub.freebsd.org (Postfix, from userid 32767) id 94AC5150E9; Fri, 18 Jun 1999 16:37:21 -0700 (PDT) Message-Id: <19990618233721.94AC5150E9@hub.freebsd.org> Date: Fri, 18 Jun 1999 16:37:21 -0700 (PDT) From: sheller@paymentnet.com To: freebsd-gnats-submit@freebsd.org X-Send-Pr-Version: www-1.0 Subject: i386/12286: Segmentation violation when invoking JNI call to C from Java with PTHREADS Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 12286 >Category: i386 >Synopsis: Segmentation violation when invoking JNI call to C from Java with PTHREADS >Confidential: no >Severity: critical >Priority: high >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jun 18 16:40:01 PDT 1999 >Closed-Date: >Last-Modified: >Originator: Steve Heller >Release: FreeBSD 3.1 RELEASE >Organization: PaymentNet, Inc. >Environment: FreeBSD yoda.paymentnet.com 3.1-RELEASE FreeBSD 3.1-RELEASE #0: Mon Feb 15 11:08:08 GMT 1999 jkh@usw3.freebsd.org:/usr/src/sys/compile/GENERIC i386 % gcc --version 2.7.2.1 >Description: When I link a static library which calls pthread routines into a shared object file with gcc -shared -pthread, and then run the java compiled program which calls it through JNI with JDK 1.1.8 (green threads), (I had to add -lc_r to the link flags in order to get pthread_mutex_lock() to be found when linking the .so file), I get the following Segmentation violation: (cd jni; java pntransjava test.paymentnet.com 443 "TRXTYPE=S&TENDER=C&PWD=g0edel 1685&USER=pnprodtest&ACCT=5105105105105100&EXPDATE=1299&AMT=27.33" 30; cd ..) SIGSEGV 11* segmentation violation Full thread dump: "Finalizer thread" (TID:0x28454210, sys_thread_t:0x29258f00, state:R) prio=1 "Async Garbage Collector" (TID:0x28454258, sys_thread_t:0x29237f00, state:R) prio=1 "Idle thread" (TID:0x284542a0, sys_thread_t:0x29216f00, state:R) prio=0 "Clock" (TID:0x28454088, sys_thread_t:0x291f5f00, state:CW) prio=12 "main" (TID:0x284540b0, sys_thread_t:0x8067700, state:R) prio=5 *current thr ead* pntransjava.main(pntransjava.java:59) Monitor Cache Dump: Registered Monitor Dump: Thread queue lock: Name and type hash table lock: String intern lock: JNI pinning lock: JNI global reference lock: BinClass lock: Class loading lock: Java stack lock: >How-To-Repeat: Write code that makes calls to pthread routines, such as pthread_mutex_lock(), and link in a static library. Write your .java file, run javah to create the .h file for inclusion in your .c file, write the .c file to implement the functions from the .h file. Run javac on the .java file, and compile the .c file. The .c file functions in turn call a function in the static library which calls pthread_mutex_lock(). Then run the java program which makes a call to the C function. The error occurs then. >Fix: On FreeBSD 2.2.7 RELEASE, I had a slightly different but seemingly similar problem which reported an Alarm clock error. I fixed it there by copying a libc_r.so.3.0 file to /usr/lib from another machine which was running FreeBSD 2.2.8 STABLE. However, I think that this file was AOUT format for FreeBSD 2.2.X, and it does not work on the FreeBSD 3.1 RELEASE platform that I have, since it is in ELF format. Does anyone either know what my problem is, or have a working version of libc_r.so.3 (ELF format) on FreeBSD 3.1? Or do I need to upgrade my gcc from 2.7.2.1 to 2.8.1? >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message