- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- compiler OK, But execute it shows Error : Segmenta...
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
Discussions
Discussions
Forums
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
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-24-2007 03:17 PM
тАО10-24-2007 03:17 PM
compiler OK, But execute it shows Error : Segmentation fault (core dumped)
I've C problem , the part of code as below:
Could anybody knows why execute it would get the Error : Segmentation fault (core dumped) ?
Thanks in advanced.
=====================================
typedef struct APC_PNDN_Lot
{
char LotId[15];
int ImpWaferCount;
char ImpWaferList[400];
char Area[10];
struct APC_PNDN_Lot* Next;
} APC_PNDN_LOT;
APC_PNDN_LOT *ptr;
ptr = (void *)(malloc (sizeof (APC_PNDN_LOT)));
ptr->ImpWaferList[0]=0x00;
ptr->LotId[0]=0x00;
ptr->Area[0]=0x00;
===========================================
Used GDB got the below:
Program received signal SIGSEGV, Segmentation fault
si_code: 1 - SEGV_MAPERR - Address not mapped to object.
0x40000000000048a0:0 in main () at APC_PNDN.c:527
527 ptr->ImpWaferList[0]=0x00;
- Tags:
- SIGSEGV
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2007 03:51 PM
тАО10-24-2007 03:51 PM
Re: compiler OK, But execute it shows Error : Segmentation fault (core dumped)
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1110034
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-24-2007 07:18 PM - edited тАО09-18-2011 02:28 PM
тАО10-24-2007 07:18 PM - edited тАО09-18-2011 02:28 PM
Re: compiler OK, But execute it shows Error: Segmentation fault
>ptr = (void*)malloc(sizeof(APC_PNDN_LOT));
This code isn't legal. The extra cast implies that there isn't any prototype for malloc.
On A.06.15 in 64 bit mode this is now a compiler error.
Make sure you include <stdlib.h>.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-27-2007 12:58 PM - edited тАО09-18-2011 02:26 PM
тАО10-27-2007 12:58 PM - edited тАО09-18-2011 02:26 PM
Re: compiler OK, But execute it shows Error: Segmentation fault
You can check this by printing ptr. It probably has the upper 32 bits truncated.
Note the proper cast is (APC_PNDN_LOT*). malloc already returns a void*.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-18-2007 02:26 PM - edited тАО09-18-2011 02:26 PM
тАО11-18-2007 02:26 PM - edited тАО09-18-2011 02:26 PM
Re: compiler OK, But execute it shows Error: Segmentation fault
We haven't heard any feedback on our suggestions. Have you solved your problem?
If our suggestions were helpful, please read the following about assigning points:
http://forums.itrc.hp.com/service/forums/helptips.do?#33