Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 18 Jun 1999 16:37:21 -0700 (PDT)
From:      sheller@paymentnet.com
To:        freebsd-gnats-submit@freebsd.org
Subject:   i386/12286: Segmentation violation when invoking JNI call to C from Java with PTHREADS
Message-ID:  <19990618233721.94AC5150E9@hub.freebsd.org>

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

>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: <unowned>
    Name and type hash table lock: <unowned>
    String intern lock: <unowned>
    JNI pinning lock: <unowned>
    JNI global reference lock: <unowned>
    BinClass lock: <unowned>
    Class loading lock: <unowned>
    Java stack lock: <unowned>

                                                                        
>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




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