Struct member alignment problem..

M

myfavdepo

Hi friends,
i am having some trouble in my prog. with struct
member alignment. I have two different static libraries that i use,
each with "struct member alignment" set to 8 bytes. In my application
it has to be 2 bytes and when i terminate the my program i am getting
this error:

DAMAGE: after Normal block (#73) at 0x00323098.
When i changed the alignment to 2 bytes for both
libraries it run and terminated with out any errors. But one of these
static libraries use tibco rendezvous, so when a message is arrived, it
is having some problems with its internal structures and i am not able
to get the message correctly.
is there is something like all the
libraries used in the application should be linked with the same
"struct member alignment"?
can someone help to solve this problem?
thanks
sreehari
 
M

myfavdepo

thanks, but that wont help me here. i tried tracing the program and
found out that inside the tibrv structure the data is wrong.
For example when a msg is received i am individually retrieving each
field in the message (which would include the messge itself). To know
what is the type of field, there is a function named getType. The
function does not return the type as a message, even though it is the
message. This is because the field is storing the data inside a
structure. When the alignment is chnged back to 8 it works fine, but
then again i am getting that heap corruption error..
 
P

Paul

structure. When the alignment is chnged back to 8 it works fine, but
then again i am getting that heap corruption error..

I would venture a guess and say it has nothing to do with the structure
alignment. All you're doing by changing the structure alignment is exposing
an existing bug in your app that really has its genesis elsewhere in your
program.

I've done the same thing by removing or adding lines of code to an app that
had nothing to do with a particular bug, and mysteriously have the bug
appear and disappear (all the while, the bug was always there, just not
exposed).

So I would suggest *not* fool around with the structure, keep it at 2 bytes,
and fix the bug. Maybe it is the structure alignment -- however you must
make sure this is the problem before tinkering with compiler options.

- Paul
 
J

Jim Langston

Paul said:
I would venture a guess and say it has nothing to do with the structure
alignment. All you're doing by changing the structure alignment is
exposing
an existing bug in your app that really has its genesis elsewhere in your
program.

I've done the same thing by removing or adding lines of code to an app
that
had nothing to do with a particular bug, and mysteriously have the bug
appear and disappear (all the while, the bug was always there, just not
exposed).

So I would suggest *not* fool around with the structure, keep it at 2
bytes,
and fix the bug. Maybe it is the structure alignment -- however you must
make sure this is the problem before tinkering with compiler options.

- Paul

Also, if you're not sure about alignment problems, try a
reinterpret_cast<char*> to the address of the returned structure and then
display the data in a console window. At lesat that way you should be able
to figure out the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top