Operating System - Linux
1748259 Members
3528 Online
108760 Solutions
New Discussion юеВ

Losing data in C structure at runtime on Itanium

 
SOLVED
Go to solution
bruneau
Occasional Advisor

Losing data in C structure at runtime on Itanium

Hi,

i have discovered a strange behaviour on an HP Itanium.

First some specs :
hp-ux 11iv2 +patchs bundles March2006
compiler : HP C/aC++ B3910B A.06.13 + patchs

The problem has been reproduced on 2 server with almost the same configuration.
We use our code for years now on PA-Risc with no trouble at all.
And the use of GCC make the problem ... disappear.

So the trouble is that, when you get into a function and get out of it by using 1 struct as parameters....
When you get out of the call of the function => the structure has been cleaned (nothing more in it.....)

The result of a test case: (code included at the end)
=====START=====
BEFORE f2 _st1.debut_nom : [debut nom de st1] - Adr[7ffcd6f0]
BEFORE f2 _st2.ref : [ref de st2] - Adr[7ffe5e38]
f2 _st1.debut_nom : [debut nom de st1] - Adr[7ffb4fa0]
f2 _st2.ref : [ref de st2] - Adr[7ffb4da0]
AFTER f2 _st1.debut_nom : [] - Adr[7ffe5e32]
AFTER f2 _st2.ref : [] - Adr[7fffe57a]
=====END=====

Before and after the f2 function call.
As you can see st1.debut_nom and _st2.ref has been cleaned and do not have the same adress anymore.

Just to repeat it : we tried to compile and run this with gcc and it worked just fine with no trouble

So the trouble (just make this little exemple to reproduce) :
============================================================
>------------------------------------------------------------------------------------------
code included in the attachement
------------------------------------------------------------------------------------------<
And to compile... you can reduce it as this
cc -g -c filec.c -o filec.o
cc -g -o filec.exe filec.o -lm -lc
------------------------------------------------------------------------------------------<


So , if someone sees a code trouble , or have any idea of what happens here...
Help or informations would be just great !
If you need more informations just ask, we really need to find out this one here.

Thanks in advance !!
xbruneau
9 REPLIES 9
Steven E. Protter
Exalted Contributor

Re: Losing data in C structure at runtime on Itanium

Shalom,

I suggest taking the same code back to pa-risc, compiling it and testing. This will eliminate the code as a suspect. Unless it blows up.

After this I suggest downloading compiler patches from itrc patch database and checking for new version of the application dvd.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Hein van den Heuvel
Honored Contributor

Re: Losing data in C structure at runtime on Itanium

Don't pass those long argments by value, pass them by reference using a pointer?!

fwiw,
Hein.
bruneau
Occasional Advisor

Re: Losing data in C structure at runtime on Itanium

Thx for your answers...

For the fact of running the application on PA-RISC....
It's ok , the test case and your entire software runs just fine on PA-Risc Arch.


For the fact of sending arguments by adress instead of values is a good idea and works better in some case (but not all)
And our software is now fairly large....
It would takes ages for us to migrate every (eventual) problem for value to adress.

And since it works fine on almost every arch we have... we would be confident in thinking it was a bug from the compiler or the linker.

No trouble on windows, sun, aix, linux, DU...
And works fine with GCC on the same server...


We have upgraded to the lastest patch.
And the trouble still here...
xbruneau
Sandman!
Honored Contributor

Re: Losing data in C structure at runtime on Itanium

I compiled your code using both ANSI C and the aCC compiler on an IPF machine B.11.23 and it works. I'm not sure how to reproduce your problem.
Sandman!
Honored Contributor

Re: Losing data in C structure at runtime on Itanium

My aC++ compiler is much older than yours. I have the B3911DB bundle of the C++ compiler installed. Don't know if that has anything to do with it.

~hope it helps
Dennis Handly
Acclaimed Contributor
Solution

Re: Losing data in C structure at runtime on Integrity

Please contact the Response Center and file a bug ASAP.

>When you get out of the call of the function => the structure has been cleaned
>do not have the same address anymore.

Right, the address register has been moved while copying the arg.

This was broken in A.06.05.

One workaround as Hein says is to not pass long structs. In fact if you copied it to a temp with memcpy, and then passed an address, it would be faster than the code the compiler generates.

Another workaround is to use +O2. Where memcpy is used.

>Sandman: My aC++ compiler is much older than yours.

(It would help if you mentioned your version rather than say "older".)

Dennis Handly
Acclaimed Contributor

Re: Losing data in C structure at runtime on Integrity

I didn't see any bug reports recently filed by you on this problem so I filed CR JAGag32532:
Bad code for large parms passed to large parms

bruneau
Occasional Advisor

Re: Losing data in C structure at runtime on Itanium

Hi,

Thanks for all your answers !

And thank you Dennis for pointing out a solution (the +O2 flag works just fine for my test case, i will try it one our application)

Thank you too , for opening the bug reports.
(i was ill and out of business for the entire week)

I will now investigate for eventual side effects.

Once again thanks !
xbruneau
bruneau
Occasional Advisor

Re: Losing data in C structure at runtime on Itanium

After some more tests.....

The +O2 do not solve our problem finally

My test case is ok for now.
But in our application the result is pretty strange.

It goes from:
-simply doing the same behaviour than without the +O2
-to display message like 'too much arguments' appear on screen at runtime..... (it appear while logging data on console)

I will have to investigate a little more to... reproduce the problem in the same way as my example do.
xbruneau