|
From: <da...@ix...> - 2003-04-15 22:19:23
|
In article <bs4...@th...>,
Mike Castle <wra...@li...> wrote:
>Hmm... I was going to try ElectricFence, but that didn't get me very far.
>Changing console() to do
>exec df $WRAPPER_CMD ...
>And core dump right away.
>
>Running NodeWarrior Analytics Server...
>
> Electric Fence 2.2.0 Copyright (C) 1987-1999 Bruce Perens
><br...@pe...>
>
>ElectricFence Aborting: Allocating 0 bytes, probably a bug.
Ok, setting EF_ALLOW_MALLOC_0 seems to fix that (bug mabye OSX has issues
with malloc(0); wouldn't think so being BSD derived, but you never know).
But that turned up another issue. Efence spits out some text on
initialization, which means the first thing wrapper sees is '\n'.
Wrapper was not amused. I had to do the following patch:
diff -u -r1.33 wrapper_unix.c
--- src/c/wrapper_unix.c 3 Apr 2003 08:10:19 -0000 1.33
+++ src/c/wrapper_unix.c 15 Apr 2003 22:07:03 -0000
@@ -360,6 +360,13 @@
startTime = now = timeBuffer.time;
startTimeMillis = nowMillis = timeBuffer.millitm;
+ if (childOutputBuffer == NULL) {
+ childOutputBuffer = malloc(1024);
+ if (childOutputBuffer != NULL) {
+ childOutputBufferSize = 1024;
+ }
+ }
+
/*
log_printf(WRAPPER_SOURCE_WRAPPER, LEVEL_DEBUG, "now=%ld, nowMillis=%d", now, nowMillis);
*/
Meanwhile, I ran a few tests with wrapper and efence and saw nothing
unusual in the current cvs code.
However, I'd like to suggest one change:
--- src/c/wrapper_unix.c 3 Apr 2003 08:10:19 -0000 1.33
+++ src/c/wrapper_unix.c 15 Apr 2003 22:11:13 -0000
@@ -213,8 +213,8 @@
/* number of arguments + 1 for a NULL pointer
at the end */
for (i = 0; i <= length; i++) {
if (i < length) {
- wrapperData->jvmCommand[i] = (char *)malloc(sizeof(char *) * strlen(strings[i]) + 1);
- sprintf(wrapperData->jvmCommand[i], strings[i]);
+ wrapperData->jvmCommand[i] = malloc(sizeof(char *) * strlen(strings[i]) + 1);
+ strcpy(wrapperData->jvmCommand[i], strings[i]);
} else {
wrapperData->jvmCommand[i] = NULL;
}
First: in _C_, one should _NEVER_ cast the return value of malloc(). If
you get warnings without it, your ether your code or compiler is broken.
Second, if strings[i] contains an %, bad things can happen in the sprintf.
mrc
--
Mike Castle da...@ix... www.netcom.com/~dalgoda/
We are all of us living in the shadow of Manhattan. -- Watchmen
fatal ("You are in a maze of twisty compiler features, all different"); -- gcc
|