Mailing List Archive

struct alignment problem - who can help? ;)
Hi list,

I am posting a question here in the hope that some of the subscribers
may be able to lend me a helping hand.

Recently, I have begun to add a testbench to rsyslog. The idea is that
over time the project should have canned tests which are easy to run on
each version (as part of make distcheck at latest), increasing the
overall code quality.

"All" (so far two ;)) tests are located in the tests subdirectory. One
test fails if compiled in release mode, that is rscript-parse.c. I have
tracked down the failure cause and it is different struct member
alignment in the ctok_token_t structure. The alignment is different in
the rsyslog runtime and this test tool (I have compared the offsets
computed for pToken->tok and they are different). So far, so good. But I
do not find the cause of this misalignment. I checked the make output,
and as it looks both the runtime as well as the tool are compiled with
the same compiler options. Also, in debug mode it works OK, but in
release mode (--disable-debug) it fails.

I am sure the problem is something quite simple, but I have run out of
ideas of what it may be (or, more probable, I simply overlook
something).

Any help would be deeply appreciated.

Thanks,
Rainer
struct alignment problem - who can help? ;) [ In reply to ]
Here is my analysis:
In ctok_teken_t, there is a BEGINobjInstance. BEGINobjInstance is a
#define and is defined to obj_t objData which is the same for both
NDEBUG defined and not defined. But obj_t is a typedef of struct
obj_s. In the structure definition for obj_s in obj-types.h are the
following lines:
#ifndef NDEBUG
unsigned int iObjCooCKiE;
#endif

NDEBUG is defined in config.h which was included in the runtime for
rsyslog but not for test-parse.c

I didn't compile the code to test my theory. I just did a quick check.

Hope that solved your problem.

Scott


I think this may be why the you are getting this structure misalignment?


On Fri, Jul 4, 2008 at 2:24 AM, Rainer Gerhards
<rgerhards at hq.adiscon.com> wrote:
> Hi list,
>
> I am posting a question here in the hope that some of the subscribers
> may be able to lend me a helping hand.
>
> Recently, I have begun to add a testbench to rsyslog. The idea is that
> over time the project should have canned tests which are easy to run on
> each version (as part of make distcheck at latest), increasing the
> overall code quality.
>
> "All" (so far two ;)) tests are located in the tests subdirectory. One
> test fails if compiled in release mode, that is rscript-parse.c. I have
> tracked down the failure cause and it is different struct member
> alignment in the ctok_token_t structure. The alignment is different in
> the rsyslog runtime and this test tool (I have compared the offsets
> computed for pToken->tok and they are different). So far, so good. But I
> do not find the cause of this misalignment. I checked the make output,
> and as it looks both the runtime as well as the tool are compiled with
> the same compiler options. Also, in debug mode it works OK, but in
> release mode (--disable-debug) it fails.
>
> I am sure the problem is something quite simple, but I have run out of
> ideas of what it may be (or, more probable, I simply overlook
> something).
>
> Any help would be deeply appreciated.
>
> Thanks,
> Rainer
> _______________________________________________
> rsyslog mailing list
> http://lists.adiscon.net/mailman/listinfo/rsyslog
>
struct alignment problem - who can help? ;) [ In reply to ]
Hi Scott,

thanks for the help, I'll further investigate. BUT: both the runtime AND
the tool are compiled in non-debug mode. So in this case, neither of
them should have the object cookie, thus the alignment should be the
same. But, as I said, I am grateful for any clue and will check if there
is some issue along these lines :) In any case, it seems to be
inconsistent and should be fixed :)

Rainer

> -----Original Message-----
> From: rsyslog-bounces at lists.adiscon.com [mailto:rsyslog-
> bounces at lists.adiscon.com] On Behalf Of Scott Phuong
> Sent: Friday, July 04, 2008 12:29 PM
> To: rsyslog-users
> Subject: Re: [rsyslog] struct alignment problem - who can help? ;)
>
> Here is my analysis:
> In ctok_teken_t, there is a BEGINobjInstance. BEGINobjInstance is a
> #define and is defined to obj_t objData which is the same for both
> NDEBUG defined and not defined. But obj_t is a typedef of struct
> obj_s. In the structure definition for obj_s in obj-types.h are the
> following lines:
> #ifndef NDEBUG
> unsigned int iObjCooCKiE;
> #endif
>
> NDEBUG is defined in config.h which was included in the runtime for
> rsyslog but not for test-parse.c
>
> I didn't compile the code to test my theory. I just did a quick check.
>
> Hope that solved your problem.
>
> Scott
>
>
> I think this may be why the you are getting this structure
> misalignment?
>
>
> On Fri, Jul 4, 2008 at 2:24 AM, Rainer Gerhards
> <rgerhards at hq.adiscon.com> wrote:
> > Hi list,
> >
> > I am posting a question here in the hope that some of the
subscribers
> > may be able to lend me a helping hand.
> >
> > Recently, I have begun to add a testbench to rsyslog. The idea is
> that
> > over time the project should have canned tests which are easy to run
> on
> > each version (as part of make distcheck at latest), increasing the
> > overall code quality.
> >
> > "All" (so far two ;)) tests are located in the tests subdirectory.
> One
> > test fails if compiled in release mode, that is rscript-parse.c. I
> have
> > tracked down the failure cause and it is different struct member
> > alignment in the ctok_token_t structure. The alignment is different
> in
> > the rsyslog runtime and this test tool (I have compared the offsets
> > computed for pToken->tok and they are different). So far, so good.
> But I
> > do not find the cause of this misalignment. I checked the make
> output,
> > and as it looks both the runtime as well as the tool are compiled
> with
> > the same compiler options. Also, in debug mode it works OK, but in
> > release mode (--disable-debug) it fails.
> >
> > I am sure the problem is something quite simple, but I have run out
> of
> > ideas of what it may be (or, more probable, I simply overlook
> > something).
> >
> > Any help would be deeply appreciated.
> >
> > Thanks,
> > Rainer
> > _______________________________________________
> > rsyslog mailing list
> > http://lists.adiscon.net/mailman/listinfo/rsyslog
> >
> _______________________________________________
> rsyslog mailing list
> http://lists.adiscon.net/mailman/listinfo/rsyslog
struct alignment problem - who can help? ;) [ In reply to ]
Hi Rainer,

But in release mode, NDEBUG is intentionally defined in the config.h.
This is what I recalled from looking at 3.16.1 and 3.17.5. So from the
perspective of rsyslog, NDEBUG is defined and the opposite for the
test-parse.c (because config.h is not included).

Scott

On Fri, Jul 4, 2008 at 3:32 AM, Rainer Gerhards
<rgerhards at hq.adiscon.com> wrote:
> Hi Scott,
>
> thanks for the help, I'll further investigate. BUT: both the runtime AND
> the tool are compiled in non-debug mode. So in this case, neither of
> them should have the object cookie, thus the alignment should be the
> same. But, as I said, I am grateful for any clue and will check if there
> is some issue along these lines :) In any case, it seems to be
> inconsistent and should be fixed :)
>
> Rainer
>
>> -----Original Message-----
>> From: rsyslog-bounces at lists.adiscon.com [mailto:rsyslog-
>> bounces at lists.adiscon.com] On Behalf Of Scott Phuong
>> Sent: Friday, July 04, 2008 12:29 PM
>> To: rsyslog-users
>> Subject: Re: [rsyslog] struct alignment problem - who can help? ;)
>>
>> Here is my analysis:
>> In ctok_teken_t, there is a BEGINobjInstance. BEGINobjInstance is a
>> #define and is defined to obj_t objData which is the same for both
>> NDEBUG defined and not defined. But obj_t is a typedef of struct
>> obj_s. In the structure definition for obj_s in obj-types.h are the
>> following lines:
>> #ifndef NDEBUG
>> unsigned int iObjCooCKiE;
>> #endif
>>
>> NDEBUG is defined in config.h which was included in the runtime for
>> rsyslog but not for test-parse.c
>>
>> I didn't compile the code to test my theory. I just did a quick check.
>>
>> Hope that solved your problem.
>>
>> Scott
>>
>>
>> I think this may be why the you are getting this structure
>> misalignment?
>>
>>
>> On Fri, Jul 4, 2008 at 2:24 AM, Rainer Gerhards
>> <rgerhards at hq.adiscon.com> wrote:
>> > Hi list,
>> >
>> > I am posting a question here in the hope that some of the
> subscribers
>> > may be able to lend me a helping hand.
>> >
>> > Recently, I have begun to add a testbench to rsyslog. The idea is
>> that
>> > over time the project should have canned tests which are easy to run
>> on
>> > each version (as part of make distcheck at latest), increasing the
>> > overall code quality.
>> >
>> > "All" (so far two ;)) tests are located in the tests subdirectory.
>> One
>> > test fails if compiled in release mode, that is rscript-parse.c. I
>> have
>> > tracked down the failure cause and it is different struct member
>> > alignment in the ctok_token_t structure. The alignment is different
>> in
>> > the rsyslog runtime and this test tool (I have compared the offsets
>> > computed for pToken->tok and they are different). So far, so good.
>> But I
>> > do not find the cause of this misalignment. I checked the make
>> output,
>> > and as it looks both the runtime as well as the tool are compiled
>> with
>> > the same compiler options. Also, in debug mode it works OK, but in
>> > release mode (--disable-debug) it fails.
>> >
>> > I am sure the problem is something quite simple, but I have run out
>> of
>> > ideas of what it may be (or, more probable, I simply overlook
>> > something).
>> >
>> > Any help would be deeply appreciated.
>> >
>> > Thanks,
>> > Rainer
>> > _______________________________________________
>> > rsyslog mailing list
>> > http://lists.adiscon.net/mailman/listinfo/rsyslog
>> >
>> _______________________________________________
>> rsyslog mailing list
>> http://lists.adiscon.net/mailman/listinfo/rsyslog
> _______________________________________________
> rsyslog mailing list
> http://lists.adiscon.net/mailman/listinfo/rsyslog
>
struct alignment problem - who can help? ;) [ In reply to ]
ROFL... you got it! I have forgotten to #include "config.h"! I knew that
it must have been something simple. Thanks a lot, you saved me from
pulling out the rest of my hair ;)

Rainer
PS: and, yes, it looks like I need to reevaluate mode-specific structure
members now that we aim at a real runtime. Doesn't look so smart any
longer...

> -----Original Message-----
> From: rsyslog-bounces at lists.adiscon.com [mailto:rsyslog-
> bounces at lists.adiscon.com] On Behalf Of Scott Phuong
> Sent: Friday, July 04, 2008 12:38 PM
> To: rsyslog-users
> Subject: Re: [rsyslog] struct alignment problem - who can help? ;)
>
> Hi Rainer,
>
> But in release mode, NDEBUG is intentionally defined in the config.h.
> This is what I recalled from looking at 3.16.1 and 3.17.5. So from the
> perspective of rsyslog, NDEBUG is defined and the opposite for the
> test-parse.c (because config.h is not included).
>
> Scott
>
> On Fri, Jul 4, 2008 at 3:32 AM, Rainer Gerhards
> <rgerhards at hq.adiscon.com> wrote:
> > Hi Scott,
> >
> > thanks for the help, I'll further investigate. BUT: both the runtime
> AND
> > the tool are compiled in non-debug mode. So in this case, neither of
> > them should have the object cookie, thus the alignment should be the
> > same. But, as I said, I am grateful for any clue and will check if
> there
> > is some issue along these lines :) In any case, it seems to be
> > inconsistent and should be fixed :)
> >
> > Rainer
> >
> >> -----Original Message-----
> >> From: rsyslog-bounces at lists.adiscon.com [mailto:rsyslog-
> >> bounces at lists.adiscon.com] On Behalf Of Scott Phuong
> >> Sent: Friday, July 04, 2008 12:29 PM
> >> To: rsyslog-users
> >> Subject: Re: [rsyslog] struct alignment problem - who can help? ;)
> >>
> >> Here is my analysis:
> >> In ctok_teken_t, there is a BEGINobjInstance. BEGINobjInstance is a
> >> #define and is defined to obj_t objData which is the same for both
> >> NDEBUG defined and not defined. But obj_t is a typedef of struct
> >> obj_s. In the structure definition for obj_s in obj-types.h are the
> >> following lines:
> >> #ifndef NDEBUG
> >> unsigned int iObjCooCKiE;
> >> #endif
> >>
> >> NDEBUG is defined in config.h which was included in the runtime for
> >> rsyslog but not for test-parse.c
> >>
> >> I didn't compile the code to test my theory. I just did a quick
> check.
> >>
> >> Hope that solved your problem.
> >>
> >> Scott
> >>
> >>
> >> I think this may be why the you are getting this structure
> >> misalignment?
> >>
> >>
> >> On Fri, Jul 4, 2008 at 2:24 AM, Rainer Gerhards
> >> <rgerhards at hq.adiscon.com> wrote:
> >> > Hi list,
> >> >
> >> > I am posting a question here in the hope that some of the
> > subscribers
> >> > may be able to lend me a helping hand.
> >> >
> >> > Recently, I have begun to add a testbench to rsyslog. The idea is
> >> that
> >> > over time the project should have canned tests which are easy to
> run
> >> on
> >> > each version (as part of make distcheck at latest), increasing
the
> >> > overall code quality.
> >> >
> >> > "All" (so far two ;)) tests are located in the tests
subdirectory.
> >> One
> >> > test fails if compiled in release mode, that is rscript-parse.c.
I
> >> have
> >> > tracked down the failure cause and it is different struct member
> >> > alignment in the ctok_token_t structure. The alignment is
> different
> >> in
> >> > the rsyslog runtime and this test tool (I have compared the
> offsets
> >> > computed for pToken->tok and they are different). So far, so
good.
> >> But I
> >> > do not find the cause of this misalignment. I checked the make
> >> output,
> >> > and as it looks both the runtime as well as the tool are compiled
> >> with
> >> > the same compiler options. Also, in debug mode it works OK, but
in
> >> > release mode (--disable-debug) it fails.
> >> >
> >> > I am sure the problem is something quite simple, but I have run
> out
> >> of
> >> > ideas of what it may be (or, more probable, I simply overlook
> >> > something).
> >> >
> >> > Any help would be deeply appreciated.
> >> >
> >> > Thanks,
> >> > Rainer
> >> > _______________________________________________
> >> > rsyslog mailing list
> >> > http://lists.adiscon.net/mailman/listinfo/rsyslog
> >> >
> >> _______________________________________________
> >> rsyslog mailing list
> >> http://lists.adiscon.net/mailman/listinfo/rsyslog
> > _______________________________________________
> > rsyslog mailing list
> > http://lists.adiscon.net/mailman/listinfo/rsyslog
> >
> _______________________________________________
> rsyslog mailing list
> http://lists.adiscon.net/mailman/listinfo/rsyslog