04-18-2008
Quote:
Originally Posted by
amitpansuria
helo my code is given below
static HeadderFun* listheader_ntoh(HeadderFun* lh)
{
lh->head_len = ntohl(lh->cl_head_len);
lh->record_len = ntohl(lh->cl_record_len);
lh->linecnt = ntohl(lh->cl_linecnt);
return lh;
}
now when i use ntohl() in the above code, i got segmentation fault.
when i remove it, application work fine.
can u tell me whats root cause of segmentation fault .
amit
Hi,
Is lh correctly initialized (malloc, etc...) ?
Is the size of lh->linecnt really a long (4-bytes) ???
10 More Discussions You Might Find Interesting
1. Programming
hi all
i'm trying to execute a c program under linux RH and it gives me segmentation fault, this program was running under unix at&t
anybody kow what the problem could be?
thanx in advance
regards (2 Replies)
Discussion started by: omran
2 Replies
2. AIX
I am tring to install Lotus Domino/Notes 5.0.5 on a AIX 4.3.3 server.
I go to run the cdrom/ibmpow/install and I get the following error.
Lotus Notes for Unix Install Program
---------------------------------------------
./install: 10088 Segmentation fault
This had Lotus Notes installed... (1 Reply)
Discussion started by: jshaulis
1 Replies
3. Programming
sometimes for this code i get a segmentation fault for codes llike this
:
int main{
int * a= 0;
int b;
a = (int*)malloc(sizeof(int));
///some code using these variable but no freeing of a
if(a){
free(a);
a = 0;
}
return... (3 Replies)
Discussion started by: wojtyla
3 Replies
4. UNIX for Dummies Questions & Answers
hello all,
I tried a program on an array to intialise array elements from the standard input device.it is an integer array of 5 elements.but after entering the 4th element it throws a message called "Segmentation Fault" and returns to the command prompt without asking for the 5th element.
... (3 Replies)
Discussion started by: compbug
3 Replies
5. Programming
ive written my code in C for implementation of a simple lexical analyser using singly linked list hence am making use of dynamic allocation,but when run in linux it gives a segmentation fault is it cause of the malloc function that ive made use of????any suggestions as to what i could do???
thank... (8 Replies)
Discussion started by: rockgal
8 Replies
6. AIX
Hi ,
During execution a backup binary i get following error
"Program error 11 (Segmentation fault), saving core file in '/usr/datatools"
Riyaz (2 Replies)
Discussion started by: rshaikh
2 Replies
7. UNIX for Advanced & Expert Users
What does this mean and why is this happening?
$ ps -ef | grep ocular
Segmentation fault (core dumped)
$ ps -ef | grep ocular
Segmentation fault (core dumped)
$ ps aux | grep ocular
Segmentation fault (core dumped)
$ ps
Segmentation fault (core dumped)
$ pkill okular
$ ps... (1 Reply)
Discussion started by: cokedude
1 Replies
8. Programming
I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this :
i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
Discussion started by: pooyair
6 Replies
9. Homework & Coursework Questions
this is a network programming code to run a rock paper scissors in a client and server.
I completed it and it was working without any error. After I added the findWinner function to the server code it starts giving me segmentation fault.
-the segmentation fault is fixed
Current problem -Also... (3 Replies)
Discussion started by: femchi
3 Replies
10. Programming
Oddities with gcc, 2.95.3 for the AMIGA and 4.2.1 for MY current OSX 10.14.1...
I am creating a basic calculator for the AMIGA ADE *NIX emulator in C as it does not have one.
Below are two very condensed snippets of which I have added the results inside the each code section.
IMPORTANT!... (11 Replies)
Discussion started by: wisecracker
11 Replies
BYTEORDER(3) Linux Programmer's Manual BYTEORDER(3)
NAME
htonl, htons, ntohl, ntohs - convert values between host and network byte order
SYNOPSIS
#include <arpa/inet.h>
uint32_t htonl(uint32_t hostlong);
uint16_t htons(uint16_t hostshort);
uint32_t ntohl(uint32_t netlong);
uint16_t ntohs(uint16_t netshort);
DESCRIPTION
The htonl() function converts the unsigned integer hostlong from host byte order to network byte order.
The htons() function converts the unsigned short integer hostshort from host byte order to network byte order.
The ntohl() function converts the unsigned integer netlong from network byte order to host byte order.
The ntohs() function converts the unsigned short integer netshort from network byte order to host byte order.
On the i386 the host byte order is Least Significant Byte first, whereas the network byte order, as used on the Internet, is Most Signifi-
cant Byte first.
ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7).
+-----------------------------------+---------------+---------+
|Interface | Attribute | Value |
+-----------------------------------+---------------+---------+
|htonl(), htons(), ntohl(), ntohs() | Thread safety | MT-Safe |
+-----------------------------------+---------------+---------+
CONFORMING TO
POSIX.1-2001, POSIX.1-2008.
Some systems require the inclusion of <netinet/in.h> instead of <arpa/inet.h>.
SEE ALSO
bswap(3), endian(3), gethostbyname(3), getservent(3)
COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the
latest version of this page, can be found at https://www.kernel.org/doc/man-pages/.
GNU 2017-09-15 BYTEORDER(3)