Re: Possible angle on JPL failures
[email protected] Sun, 21 Jan 2001 11:37:46 -0800 (PST)
| Newsgroups | perl.jpl |
|---|---|
| Message-ID | <[email protected]> |
> I can force core dumps with a Kaffe/perl5.6.0 JPL setup, but they seem to be
> related to lack of initialization of data structures inside Kaffe's JVM.
> (i.e., before any Perl code runs, I have to do a bunch of JNI-related stuff,
> otherwise a core dump).
> Basically, in any JPL program I add:
> BEGIN {
>
> use JPL::AutoLoader;
> use JPL::Class 'java::lang::StringBuffer';
>
> my $sb = java::lang::StringBuffer->new__s("STOP KAFFE FROM CRASHING");
>}
>And it always seem to work, at least for Kaffe.
>Give that work around a try and see if it effects your core dumps.
> If not, *you* may have the best setup to help us find the bug. Your
> environment-diddling theory has some promise. Does anyone on this list know
> the perl internals enough to see what it would take to have Perl dup the
> environment instead of diddling it directly?
I tried the Kaffe fix but unfortunately got a core.
However, without knowing what I was doing, I hacked a
quick 'n dirty dup of the environment and -- I nearly
fell off the chair -- JPL worked with jdk 1.3 !!.
At least this proves the theory although I'm sure there's
a better idiom for the fix. Anyway I've included the perl.c
patch below:
Regards,
--
Charles DeRykus
*** perl.c.orig Sun Jan 21 09:25:04 2001
--- perl.c Sun Jan 21 09:27:20 2001
***************
*** 11,20 ****
--- 11,27 ----
* "A ship then new they built for him/of mithril and of elven glass" --Bilbo
*/
+ /* JPL quick fix */
+ char *my_env_ptr;
+ char **my_env, **my_env_base, **env_base;
+ int my_env_count = 0;
+
+
#include "EXTERN.h"
#include "perl.h"
#include "patchlevel.h"
+
/* XXX If this causes problems, set i_unistd=undef in the hint file. */
#ifdef I_UNISTD
#include <unistd.h>
***************
*** 2586,2592 ****
}
STATIC void
! init_postdump_symbols(register int argc, register char **argv, register char **env)
{
dTHR;
char *s;
--- 2593,2599 ----
}
STATIC void
! init_postdump_symbols(register int argc, register char **argv, register char **env )
{
dTHR;
char *s;
***************
*** 2644,2666 ****
if the environment has been modified since. To avoid this
problem we treat env==NULL as meaning 'use the default'
*/
! if (!env)
env = environ;
! if (env != environ)
environ[0] = Nullch;
for (; *env; env++) {
! if (!(s = strchr(*env,'=')))
continue;
*s++ = '\0';
#if defined(MSDOS)
! (void)strupr(*env);
#endif
sv = newSVpv(s--,0);
! (void)hv_store(hv, *env, s - *env, sv, 0);
*s = '=';
#if defined(__BORLANDC__) && defined(USE_WIN32_RTL_ENV)
/* Sins of the RTL. See note in my_setenv(). */
! (void)PerlEnv_putenv(savepv(*env));
#endif
}
#endif
--- 2651,2692 ----
if the environment has been modified since. To avoid this
problem we treat env==NULL as meaning 'use the default'
*/
! if (!env) {
env = environ;
! }
! if (env != environ) {
environ[0] = Nullch;
+ }
+
+ /* create dummy env for JPL quick fix */
+ env_base = env;
+ for (; *env; env++) {
+ my_env_count++;
+ }
+ my_env = (char **) safemalloc( sizeof(char **) * (my_env_count+1) );
+ my_env_base = my_env;
+ env = env_base;
for (; *env; env++) {
! my_env_ptr = (char *) safemalloc( sizeof(char) * (strlen(*env)+1) );
! strcpy( my_env_ptr, *env );
! *my_env = my_env_ptr;
! my_env++;
! }
! *my_env = '\0';
! my_env = my_env_base;
! for (; *my_env; my_env++) {
! if (!(s = strchr(*my_env,'=')))
continue;
*s++ = '\0';
#if defined(MSDOS)
! (void)strupr(*my_env);
#endif
sv = newSVpv(s--,0);
! (void)hv_store(hv, *my_env, s - *my_env, sv, 0);
*s = '=';
#if defined(__BORLANDC__) && defined(USE_WIN32_RTL_ENV)
/* Sins of the RTL. See note in my_setenv(). */
! (void)PerlEnv_putenv(savepv(*my_env));
#endif
}
#endif
***************
*** 2669,2676 ****
#endif
}
TAINT_NOT;
! if (tmpgv = gv_fetchpv("$",TRUE, SVt_PV))
sv_setiv(GvSV(tmpgv), (IV)getpid());
}
STATIC void
--- 2695,2703 ----
#endif
}
TAINT_NOT;
! if (tmpgv = gv_fetchpv("$",TRUE, SVt_PV)) {
sv_setiv(GvSV(tmpgv), (IV)getpid());
+ }
}
STATIC void