Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 06 Apr 1998 10:09:48 -0400 (EDT)
From:      "Eric A. Griff" <eric@NetDesign1.Com>
To:        bugs@apache.org
Cc:        java@FreeBSD.ORG
Subject:   Segfault trying to use Java JNI in Apache
Message-ID:  <XFMail.980406100948.eric@NetDesign1.Com>

next in thread | raw e-mail | index | archive | help
I am trying to write a module (Apache API) that makes use of java's native
interface
so it can use some of Java's functionality. However, it seems that 
whenever I try to link in libjava.so, it causes apache to Segfault
at numerous points. The ones I have spotted are at getpwent in uname2id

I was trying to build an apache module, that uses the Java Native
Interface in Java 1.1.5, on FreeBSD 2.2.5-STABLE, last updated in February.

It segfaults while calling getpwent in uname2id (in apache). What am I doing
wrong? Where might the problem be (Java Implementation, Apache, or the
Java Virtual Machine in general?). If I change the name[] var to a # format
it get's past there, just to segfault further on. Below is some 
further information..


//// version info
sh-2.01$ java -version
java version "jdk1.1-dap:1998/01/07-05:19"
sh-2.01$ uname -a
FreeBSD Chat.NetDesign1.Com 2.2.5-STABLE FreeBSD 2.2.5-STABLE #1: Wed Mar 25
15:35:10 EST 1998     root@Chat.NetDesign1.Com:/sp
/src/sys/compile/CHAT  i386
sh-2.01$ ~/apache/httpd -v
Server version Apache/1.3b5.
Server built:  Apr  4 1998 14:28:32

The FreeBSD is built from a cvsup around

Apache Configuration Stuff (from apache_1.3b5/src/Configuration used):
PREFIX=/home/zch

EXTRA_CFLAGS=\
-DHTTPD_ROOT=\"${PREFIX}/apache/\" \
-DDOCUMENT_LOCATION=\"${PREFIX}/apache/wwwdocs/\" \
-DSERVER_CONFIG_FILE=\"conf/httpd.conf\" \
-DRESOURCE_CONFIG_FILE=\"conf/srm.conf\" \
-DTYPES_CONFIG_FILE=\"conf/mime.types\" \
-DACCESS_CONFIG_FILE=\"conf/access.conf\" \
-DDEFAULT_PATH=\"/bin:/usr/bin:/usr/local/bin:${PREFIX}/bin\" \
-DSUEXEC_BIN=\"${PREFIX}/suexec\" \
-DDEFAULT_XFERLOG=\"${PREFIX}/apache/logs/access.log\" \
-DDEFAULT_ERRORLOG=\"${PREFIX}/apache/logs/error.log\" \
-DDEFAULT_PIDLOG=\"${PREFIX}/apache/logs/httpd.pid\" \
-DDEFAULT_SCOREBOARD=\"${PREFIX}/apache/logs/apache_runtime_status\" \
-DDEFAULT_LOCKFILE=\"${PREFIX}/apache/logs/accept.lock\" \
-DMAGIC=\"conf/magic\"

#SEGFAULTS at getpwname in uname2id(main/util.c:1405). If name[] in that
#function is changed to the "#x.." format, it will segfault elsewhere,
#such as line 1407 in that file, and beyond.
EXTRA_LDFLAGS=-L/usr/local/java/lib/i386/green_threads
EXTRA_LIBS=-ljava
EXTRA_INCLUDES=-I/usr/local/java/include -I/usr/local/java/include/freebsd

#Works
#EXTRA_LDFLAGS=
#EXTRA_LIBS=
#EXTRA_INCLUDES=

#CC=
OPTIM=-g 
#RANLIB=

Script started on Sat Apr  4 14:37:55 1998
sh-2.01$ gdb ~zch/apache/httpd 
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.16 (i386-unknown-freebsd), 
Copyright 1996 Free Software Foundation, Inc...
(gdb) set args httpd -d /home/zch/apache -f conf/httpd.conf
(gdb) break uname2id
Breakpoint 1 at 0x38afe: file util.c, line 1405.
(gdb) run
Starting program: /home/zch/apache/httpd httpd -d /home/zch/apache -f
conf/httpd.conf

Breakpoint 1, uname2id (name=0x2cfc6 "nobody") at util.c:1405
1405        if (name[0] == '#')
(gdb) l
1400    #ifdef WIN32
1401        return (1);
1402    #else
1403        struct passwd *ent;
1404    
1405        if (name[0] == '#')
1406            return (atoi(&name[1]));
1407    
1408        if (!(ent = getpwnam(name))) {
1409            fprintf(stderr, "httpd: bad user name %s\n", name);
(gdb) print name
$1 = 0x2cfc6 "nobody"
(gdb) s
1408        if (!(ent = getpwnam(name))) {
(gdb) s

Program received signal SIGSEGV, Segmentation fault.
0x0 in ?? ()
(gdb) quit
The program is running.  Quit anyway (and kill it)? (y or n) y
sh-2.01$ 
Script done on Sat Apr  4 14:39:23 1998

It happens even if no module uses libjava.so . 


Thanks for any Feed-Back.
Eric A. Griff,
Programmer,
NETDesign Inc.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message



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