- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: C Src code giving CORE dump
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2008 11:49 PM
10-13-2008 11:49 PM
I am migrating my applciation from 32bit to 64bit. AFter successful compilation executable is giving core dump. After using Debugging statement i found the point of failure.
static char *PIDfilename;
PIDfilename = (char *) malloc(strlen("var/") + strlen(processName) + strlen(".pid") + 1);
*PIDfilename = '\0';
strcat(PIDfilename, "var/");
strcat(PIDfilename, processName);
strcat(PIDfilename, ".pid");
EOC
line where \0 is assign is giving core dump I have tried with NULL, strcpy..all statement is fiving core dump.
Can anyone suggest on this.
Thanks
Bhushan
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 01:52 AM
10-14-2008 01:52 AM
Re: C Src code giving CORE dump
Things to check:
- Is the "processName" variable properly initialized at the point malloc() is executed?
- Did the malloc() operation complete successfully, or did it fail?
(If it failed, the assignment is doomed to fail. The application should at least detect this and try to exit in a controlled manner, preferably after outputting a meaningful error message.)
- Is there anything in between the malloc() operation and the assignment to "*PIDfilename" that might corrupt the value of the "PIDfilename" pointer?
(In the code you have shown, there is nothing. But this code is obviously incomplete - have you snipped away something from between these lines?)
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 03:43 AM
10-14-2008 03:43 AM
Re: C Src code giving CORE dump
But when i compiled with 64bit then attached code is not working and giving core dump.
This a complete code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 03:58 AM
10-14-2008 03:58 AM
SolutionVMS, you seem to be missing some crucial
header files. For example:
alp $ cc 313166.C_ORIG
PIDfilename = (char *) malloc(strlen("/EEH/var/") + strlen(processName)
+ strlen(".pid") + 1);
...............................^
%CC-I-IMPLICITFUNC, In this statement, the identifier "malloc" is implicitly declared as a function.
at line number 24 in file ALP$DKA0:[SMS.ITRC]313166.C_ORIG;1
[...]
If your compiler thinks that malloc() is an
"int", then you might losing 32 bits worth of
pointer there.
How are you compiling this without getting a
bunch of warnings?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 04:35 AM
10-14-2008 04:35 AM
Re: C Src code giving CORE dump
So you malloc result is truncated.
you can also do
extern void * malloc(int);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 04:53 AM
10-14-2008 04:53 AM
Re: C Src code giving CORE dump
> bunch of warnings?
I'm still wondering about this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 04:57 AM
10-14-2008 04:57 AM
Re: C Src code giving CORE dump
If any issue arise will update.
Anyway after including the stdlib warning messge has gone.
Thanks
Bhushan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 05:09 AM
10-14-2008 05:09 AM
Re: C Src code giving CORE dump
> messge has gone.
Perhaps that warning, whatever it was, was
trying to tell you something important. You
learned the lesson here, right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 09:50 PM
10-14-2008 09:50 PM
Re: C Src code giving CORE dump
Also, you can use +w64bit and +wlint to check for clean programs.
If you are still on PA, you can download cadvise to do the same things:
http://www.hp.com/go/cadvise
>strlen("var/")
You can optimize this to:
(sizeof("var/")-1)
*PIDfilename = '\0';
strcat(PIDfilename, "var/");
Instead of doing this null assignment, you should change the first to strcpy(3).
- Tags:
- +wlint
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 09:55 PM
10-14-2008 09:55 PM
Re: C Src code giving CORE dump
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 11:35 PM
10-14-2008 11:35 PM
Re: C Src code giving CORE dump
for things like this you should simply use a scripting language like perl or python. you could probably turn it into a shell script just as well.
i used to be pretty good at C, but i don't see the need to use it anymore. for admin work there is nothing that can't be done with shell and perl scripting.
even when i fiddle around with desktop apps on linux, this is written in python (with glade/gtk), nobody notices the difference.
it's so easy, fast and you don't have to worry about things like pointers and memory allocations.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2008 11:52 PM
10-14-2008 11:52 PM
Re: C Src code giving CORE dump
Yes but it must be a small fragment since there would be no reason to compile with +DD64.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2008 10:21 PM
10-16-2008 10:21 PM
Re: C Src code giving CORE dump
i'm saying, sometimes people do things out of habbit or because they read it somewhere and applied it without knowing what all the options stand for.