X-MimeOLE: Produced By Microsoft Exchange V6.5
Received: by onstor-exch02.onstor.net 
	id <01C70906.41775EB3@onstor-exch02.onstor.net>; Wed, 15 Nov 2006 14:34:47 -0800
MIME-Version: 1.0
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C70906.41775EB3"
Content-class: urn:content-classes:message
Subject: vsnprintf problem
Date: Wed, 15 Nov 2006 14:34:47 -0800
Message-ID: <BB375AF679D4A34E9CA8DFA650E2B04E0138C31A@onstor-exch02.onstor.net>
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
Thread-Topic: vsnprintf problem
thread-index: AccJBkGqKaTBUxn6SfWIojo0tH1JJA==
From: "Chris Vandever" <chris.vandever@onstor.com>
To: "Andy Sharp" <andy.sharp@onstor.com>

This is a multi-part message in MIME format.

------_=_NextPart_001_01C70906.41775EB3
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

The source file I'm having problems with is
~chrisv/p4/lambo/nfx-tree/code/ssc-cluster/clusdb-rec-r122.c.  The
problem is with a CLUSTER_PRINTF() at line 417.  Similar
CLUSTER_PRINTF()'s in code/ssc-cluster/cluster-vol-api.c work fine.  The
former file is only used in building the cluster_server app, while the
latter is used to build libcluster.so, and the code is then exercised by
the cluster_contrl app.  CLUSTER_PRINTF() is a macro that wraps the
standard E_LOG() macro, which eventually works its way into vsnprintf().

What happens is that the 64-bit quantity in volCfg.id.whole_thing is off
by 32-bits when it gets stuffed into the formatted string, so part of
the value is correct, but part is from the wrong neighboring word.  This
ends up shifting the remaining parameters, resulting in a SEGV trying to
get the length of the string parameter that it's trying to pick up from
the wrong location.

I've tried replacing the CLUSTER_PRINTF() macro with a direct E_LOG()
call without any change in the symptoms.  I've tried doing a clean build
of ssc-cluster with -DRELIABLE_LOG defined in the Makefile.  This define
enables an alternate definition of CLUSTER_PRINTF() that calls a
function private to clustering that calls vsnprintf() directly to write
to a log file, before later calling E_LOG().  Again, no change.

The edits to the file are in 3 major areas:  (1) Make the include file
list match what seems to work in cluster-vol-api.c.  The resulting
dependency files are identical, except for the addition of clusdb-api.c,
which contains only function prototypes for clusDb_*() functions.  (2)
Ifdef out the functions that need the missing include files.  (3) Add
the offending CLUSTER_PRINTF().

Since I get the same symptom from the more direct use of vsnprintf() I
don't think it's related to E_LOG per se.  Since I've pared down the
file to use the same includes as the file that works I don't think it's
the include files.

I have my filer set up to exercise the code, as it requires trying to
upgrade the cluster database from version R1.3 to R2.1.

If you have some time to drop by and take a look at this I'd appreciate
it.  I'd really like to be able to log errors from the functions in this
file that include the 64-bit volume ID.  Thanks.

ChrisV


------_=_NextPart_001_01C70906.41775EB3
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">
<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version =
6.5.7650.28">
<TITLE>vsnprintf problem</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/rtf format -->

<P ALIGN=3DLEFT><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">The =
source file I</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">&#8217;</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">m having problems with is =
~chrisv/p4/lambo/nfx-tree/code/ss</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">c</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">-cluster/clusdb-rec-r122.c</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">.&nbsp; The problem is with a =
CLUSTER_PRINTF()</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial"> at line =
41</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT =
SIZE=3D2 FACE=3D"Arial">7</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">.&nbsp;</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"> <FONT SIZE=3D2 =
FACE=3D"Arial">S</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">imilar =
CLUSTER_PRINTF()</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">&#8217;</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">s</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial"> in =
code/ssc-cluster/cluster-vol-api.c</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial"> work fine.&nbsp; The former file is only used in =
building the cluster_server app, while the latter is used to build =
libcluster.so, and the code is then exercised by the cluster_contrl =
app.&nbsp; CLUSTER_PRINTF() is a macro that wraps the standard E_LOG() =
macro, which eventually works its way into =
vsnprintf().</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"></SPAN></P>

<P ALIGN=3DLEFT><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">What =
happens is that the 64-bit quantity</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"> <FONT SIZE=3D2 =
FACE=3D"Arial">in</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial"> volCfg.id.whole_thing =
is</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"> <FONT =
SIZE=3D2 FACE=3D"Arial">off by 32-bits</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial"> when it gets stuffed into the formatted =
string</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">, so part of the value is =
correct, but part is from the wrong neighboring word.&nbsp; This ends up =
shifting the remaining parameters, resulting in a SEGV trying to get the =
length of the string parameter that</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"> <FONT SIZE=3D2 =
FACE=3D"Arial">it</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">&#8217;</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">s trying to pick up from the wrong =
location.</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"></SPAN></P>

<P ALIGN=3DLEFT><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">I</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">&#8217;</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">ve tried replacing the CLUSTER_PRINTF() macro with a =
direct E_LOG() call without any change in the =
symptoms.</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">&nbsp; I</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">&#8217;</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">ve tried doing a clean =
build of ssc-cluster with -DRELIABLE_LOG defined in the Makefile.&nbsp; =
This define enables an alternate definition of CLUSTER_PRINTF() that =
calls a function private to clustering that calls vsnprintf() =
directly</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial"> to write to a log =
file</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT =
SIZE=3D2 FACE=3D"Arial">, before later calling E_LOG().&nbsp; Again, no =
change.</FONT></SPAN></P>

<P ALIGN=3DLEFT><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">The =
edits to the file are in 3 major areas:&nbsp; (1)</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"> <FONT SIZE=3D2 =
FACE=3D"Arial">M</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">ake the include file list =
match what seems to work in cluster-vol-api.c.</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">&nbsp; The resulting dependency files are identical, =
except for the addition of clusdb-api.c, which contains only function =
prototypes for clusDb_*() functions.&nbsp; (2) Ifdef out the functions =
that need the missing include files.&nbsp; (3) Add the offending =
CLUSTER_PRINTF().</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"></SPAN></P>

<P ALIGN=3DLEFT><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">Since =
I get the same symptom from the more direct use of vsnprintf() I =
don</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT =
SIZE=3D2 FACE=3D"Arial">&#8217;</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">t think it</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">&#8217;</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">s related to E_LOG per se.&nbsp; Since =
I</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT =
SIZE=3D2 FACE=3D"Arial">&#8217;</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">ve pared down the file to use the same includes as the =
file that works I don</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">&#8217;</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">t think it</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">&#8217;</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">s the include files.</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"></SPAN></P>

<P ALIGN=3DLEFT><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">I =
have my filer set up to exercise the code, as it requires trying to =
upgrade the cluster database from version R1.3 to =
R2.1.</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"></SPAN></P>

<P ALIGN=3DLEFT><SPAN LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">If =
you have some time to drop by and take a look at this =
I</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT =
SIZE=3D2 FACE=3D"Arial">&#8217;</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">d appreciate it.&nbsp; I</FONT></SPAN><SPAN =
LANG=3D"en-us"></SPAN><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">&#8217;</FONT></SPAN><SPAN LANG=3D"en-us"></SPAN><SPAN =
LANG=3D"en-us"><FONT SIZE=3D2 FACE=3D"Arial">d really like to be able to =
log errors from the functions in this file that include the 64-bit =
volume ID.&nbsp; Thanks.</FONT></SPAN></P>

<P ALIGN=3DLEFT><SPAN LANG=3D"en-us"><FONT SIZE=3D2 =
FACE=3D"Arial">ChrisV</FONT></SPAN></P>

</BODY>
</HTML>
------_=_NextPart_001_01C70906.41775EB3--
