Re: problem c-program (memory fault) (367 Views)
Reply
Occasional Advisor
Derko Drukker
Posts: 13
Registered: ‎05-01-2003
Message 1 of 9 (367 Views)

problem c-program (memory fault)

We compiled a c-source on an HP-UX server (hp-ux 11.11, PA 2.0, lets call this server "A") but it will not run on A: Memory fault(coredump).
So we compiled exactly the same c-source on another server (hp-ux 10.20, PA 1.1, lets call this server "B") and it runs perfectly on B.
Now we took the executable from B to A and it wil not run: Memory fault(coredump).
And when we take the executable from A to B and it runs perfectly.
So both compiled executables will run: on B. And both executables will not run on A.
FYI: server A has far more memory than server B.

Putting this problem so 'general' as above: does anyone have a good idea where to look first?

(We also compiled on "C" (hp-ux 11.00 PA 2.0) and this has the same effect: the executable will not run on A (memory fault) and it run's on B; it will not run on C)
Honored Contributor
Gopi Sekar
Posts: 877
Registered: ‎04-25-2005
Message 2 of 9 (367 Views)

Re: problem c-program (memory fault)


try creating a simple hello world program and see whether it runs on server A. if it is then the more likely issue could be your C program, the way it initiates the program memory.

check for the change log between 10.20 and 11.00 and see whether there is anything specific to memory module is mentioned.

Regards,
Gopi
Never Never Never Giveup
Honored Contributor
H.Merijn Brand (procura
Posts: 6,189
Registered: ‎10-13-1997
Message 3 of 9 (367 Views)

Re: problem c-program (memory fault)

You should use a debugger (gdb, adb, ...) to show us the stack trace of the core dump.

It could as well be a shared library that misbehavess, or - in case of (n)curses programs - a misconfigured termcap or terminfo entry

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Occasional Advisor
Derko Drukker
Posts: 13
Registered: ‎05-01-2003
Message 4 of 9 (367 Views)

Re: problem c-program (memory fault)

adb and $c produces:

adb>$c
main(1,7F7F094C) from main+8
main+8_end($START$+1A0
$START$+1A0
adb>

gdb calc_statistic_lml core produces:

Core was generated by `calc_statistic'.
Program terminated with signal 11, Segmentation fault.
#0 0x1d00c in main (argc=1, argv=0x7f7f094c) at calc_statistic_lml.c:200
200 sessie = 1;
(gdb)

This is all abacadabra to me. To you ?



Honored Contributor
H.Merijn Brand (procura
Posts: 6,189
Registered: ‎10-13-1997
Message 5 of 9 (367 Views)

Re: problem c-program (memory fault)

] adb and $c produces:
]
] adb>$c
] main(1,7F7F094C) from main+8
] main+8_end($START$+1A0
] $START$+1A0
] adb>

Your stack is corrupted

] gdb calc_statistic_lml core produces:
]
] Core was generated by `calc_statistic'.
] Program terminated with signal 11, Segmentation fault.
] #0 0x1d00c in main (argc=1, argv=0x7f7f094c) at calc_statistic_lml.c:200
] 200 sessie = 1;
] (gdb)
]
] This is all abacadabra to me. To you ?

please show us the function that is defined in calc_statistics_lml.c about line 200 and make sure that it includes the function header. For example

line:code

195:int main (int argc, char *argv[])
196:{
197: short foo;
198:
199: foo = 1;
200: *((long long *)&foo) = 12345678L;

Just to give you an example of what could cause such a core dump

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
Trusted Contributor
Amit Agarwal_1
Posts: 153
Registered: ‎06-02-2004
Message 6 of 9 (367 Views)

Re: problem c-program (memory fault)

Okay, one thing is clear that your application runs on 10.20 but fails on 11.11 irrespective of compiler that you use.
Now I see that there can be one of two reasons for this:
1) There is incompatibility introduced in 11.11, I am not sure how to cathc this or corrcet this.
2) The application has some null dereference statement or unitialized pointer dereference. In this case I would suggest you to use some lint software to see if there is any trivial bug. Verify the printf statements to see that the number of arguments matches with the format string requirements. Similarly look for other varargs statements. This should be straightforward as you already know the function that is causing memory fault.

Having said everything, I am great admirer of gdb and owuld suggest you to continue using that to locate the issue.

-Amit
Occasional Advisor
Derko Drukker
Posts: 13
Registered: ‎05-01-2003
Message 7 of 9 (367 Views)

Re: problem c-program (memory fault)

Problem solved.

I increased kernel-variable MAXSSIZ and then it worked.

Thank you all.
Trusted Contributor
Amit Agarwal_1
Posts: 153
Registered: ‎06-02-2004
Message 8 of 9 (367 Views)

Re: problem c-program (memory fault)

I am surprised to see memory fault error. Shouldn't it give stack overflow error here? Please correct me if i am wrong.

Anyway learned something new.:-)
Occasional Visitor
Manish Chhetri
Posts: 1
Registered: ‎07-27-2005
Message 9 of 9 (367 Views)

Re: problem c-program (memory fault)

I was trying to modify an existing program which writes to a file. I have been trying to write an extra field to the file, but it gives me a memory fault (core). Is it due to the MAXSIZ setting again? or something else?
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.