LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-02-2012, 02:49 AM   #1
santhosh-e
LQ Newbie
 
Registered: Jan 2012
Posts: 5

Rep: Reputation: Disabled
regarding segv signal


hi,

I have build the image for coldfire processor using build root 2011.08.Here we are using busybox version 1.18.5 and linux kernel 2.6.30.4.we try to download the image its works fine we got the prompt and file system.While pinging from the device i am facing segv error.

Here code is :
static void sendping_tail(void (*sp)(int), const void *pkt, int size_pkt)
{

int sz;

CLR((uint16_t)ntransmitted % MAX_DUP_CHK);
ntransmitted++;

/* sizeof(pingaddr) can be larger than real sa size, but I think
* it doesn't matter */
sz = xsendto(pingsock, pkt, size_pkt, &pingaddr.sa, sizeof(pingaddr));
if (sz != size_pkt)
bb_error_msg_and_die(bb_msg_write_error);

if (pingcount == 0 || deadline || ntransmitted < pingcount) {
/* Didn't send all pings yet - schedule next in 1s */
signal(SIGALRM, sp);



if (deadline) {
total_secs += PINGINTERVAL;
if (total_secs >= deadline)
signal(SIGALRM, print_stats_and_exit);
}
alarm(PINGINTERVAL);


} else { /* -c NN, and all NN are sent (and no deadline) */
/* Wait for the last ping to come back.
* -W timeout: wait for a response in seconds.
* Affects only timeout in absense of any responses,
* otherwise ping waits for two RTTs. */
unsigned expire = timeout;

if (nreceived) {
/* approx. 2*tmax, in seconds (2 RTT) */
expire = tmax / (512*1024);
if (expire == 0)
expire = 1;
}
signal(SIGALRM, print_stats_and_exit);
alarm(expire);
}

}

static void sendping4(int junk UNUSED_PARAM)
{
struct icmp *pkt = G.snd_packet;

//memset(pkt, 0, datalen + ICMP_MINLEN + 4); - G.snd_packet was xzalloced
pkt->icmp_type = ICMP_ECHO;
/*pkt->icmp_code = 0;*/
pkt->icmp_cksum = 0; /* cksum is calculated with this field set to 0 */
pkt->icmp_seq = htons(ntransmitted); /* don't ++ here, it can be a macro */
pkt->icmp_id = myid;

/* If datalen < 4, we store timestamp _past_ the packet,
* but it's ok - we allocated 4 extra bytes in xzalloc() just in case.
*/
/*if (datalen >= 4)*/
/* No hton: we'll read it back on the same machine */
*(uint32_t*)&pkt->icmp_dun = monotonic_us();

pkt->icmp_cksum = in_cksum((unsigned short *) pkt, datalen + ICMP_MINLEN);

signal(SIGALRM,sendping4);
sendping_tail(sendping4, pkt, datalen + ICMP_MINLEN);
}

static void ping4(len_and_sockaddr *lsa)
{
int sockopt;

pingsock = create_icmp_socket();
pingaddr.sin = lsa->u.sin;
if (source_lsa) {
if (setsockopt(pingsock, IPPROTO_IP, IP_MULTICAST_IF,
&source_lsa->u.sa, source_lsa->len))
bb_error_msg_and_die("can't set multicast source interface");
xbind(pingsock, &source_lsa->u.sa, source_lsa->len);
}
if (str_I)
setsockopt_bindtodevice(pingsock, str_I);

/* enable broadcast pings */
setsockopt_broadcast(pingsock);

/* set recv buf (needed if we can get lots of responses: flood ping,
* broadcast ping etc) */
sockopt = (datalen * 2) + 7 * 1024; /* giving it a bit of extra room */
setsockopt(pingsock, SOL_SOCKET, SO_RCVBUF, &sockopt, sizeof(sockopt));

signal(SIGINT, print_stats_and_exit);

/* start the ping's going ... */

sendping4(0);



/* listen for replies */
while (1) {
printf("listen for replies\n");
sendping4(0);

struct sockaddr_in from;
socklen_t fromlen = (socklen_t) sizeof(from);
int c;

c = recvfrom(pingsock, G.rcv_packet, G.sizeof_rcv_packet, 0,
(struct sockaddr *) &from, &fromlen);


if (c < 0) {
if (errno != EINTR)
bb_perror_msg("recvfrom");
continue;

}

}



We tried to debug the transmission and reception happens one time after that i am getting segv error.

please any ideas it will be helpful for debug the code.

regards
santhosh babu
 
Old 01-02-2012, 03:27 AM   #2
santhosh-e
LQ Newbie
 
Registered: Jan 2012
Posts: 5

Original Poster
Rep: Reputation: Disabled
hi,

I have build the image for coldfire processor using build root 2011.08.Here we are using busybox version 1.18.5 and linux kernel 2.6.30.4.we try to download the image its works fine we got the prompt and file system.While pinging from the device i am facing segv error.

Here code is :
static void sendping_tail(void (*sp)(int), const void *pkt, int size_pkt)
{

int sz;

CLR((uint16_t)ntransmitted % MAX_DUP_CHK);
ntransmitted++;

/* sizeof(pingaddr) can be larger than real sa size, but I think
* it doesn't matter */
sz = xsendto(pingsock, pkt, size_pkt, &pingaddr.sa, sizeof(pingaddr));
if (sz != size_pkt)
bb_error_msg_and_die(bb_msg_write_error);

if (pingcount == 0 || deadline || ntransmitted < pingcount) {
/* Didn't send all pings yet - schedule next in 1s */
signal(SIGALRM, sp);



if (deadline) {
total_secs += PINGINTERVAL;
if (total_secs >= deadline)
signal(SIGALRM, print_stats_and_exit);
}
alarm(PINGINTERVAL);


} else { /* -c NN, and all NN are sent (and no deadline) */
/* Wait for the last ping to come back.
* -W timeout: wait for a response in seconds.
* Affects only timeout in absense of any responses,
* otherwise ping waits for two RTTs. */
unsigned expire = timeout;

if (nreceived) {
/* approx. 2*tmax, in seconds (2 RTT) */
expire = tmax / (512*1024);
if (expire == 0)
expire = 1;
}
signal(SIGALRM, print_stats_and_exit);
alarm(expire);
}

}

static void sendping4(int junk UNUSED_PARAM)
{
struct icmp *pkt = G.snd_packet;

//memset(pkt, 0, datalen + ICMP_MINLEN + 4); - G.snd_packet was xzalloced
pkt->icmp_type = ICMP_ECHO;
/*pkt->icmp_code = 0;*/
pkt->icmp_cksum = 0; /* cksum is calculated with this field set to 0 */
pkt->icmp_seq = htons(ntransmitted); /* don't ++ here, it can be a macro */
pkt->icmp_id = myid;

/* If datalen < 4, we store timestamp _past_ the packet,
* but it's ok - we allocated 4 extra bytes in xzalloc() just in case.
*/
/*if (datalen >= 4)*/
/* No hton: we'll read it back on the same machine */
*(uint32_t*)&pkt->icmp_dun = monotonic_us();

pkt->icmp_cksum = in_cksum((unsigned short *) pkt, datalen + ICMP_MINLEN);

signal(SIGALRM,sendping4);
sendping_tail(sendping4, pkt, datalen + ICMP_MINLEN);
}

static void ping4(len_and_sockaddr *lsa)
{
int sockopt;

pingsock = create_icmp_socket();
pingaddr.sin = lsa->u.sin;
if (source_lsa) {
if (setsockopt(pingsock, IPPROTO_IP, IP_MULTICAST_IF,
&source_lsa->u.sa, source_lsa->len))
bb_error_msg_and_die("can't set multicast source interface");
xbind(pingsock, &source_lsa->u.sa, source_lsa->len);
}
if (str_I)
setsockopt_bindtodevice(pingsock, str_I);

/* enable broadcast pings */
setsockopt_broadcast(pingsock);

/* set recv buf (needed if we can get lots of responses: flood ping,
* broadcast ping etc) */
sockopt = (datalen * 2) + 7 * 1024; /* giving it a bit of extra room */
setsockopt(pingsock, SOL_SOCKET, SO_RCVBUF, &sockopt, sizeof(sockopt));

signal(SIGINT, print_stats_and_exit);

/* start the ping's going ... */

sendping4(0);



/* listen for replies */
while (1) {
printf("listen for replies\n");
sendping4(0);

struct sockaddr_in from;
socklen_t fromlen = (socklen_t) sizeof(from);
int c;

c = recvfrom(pingsock, G.rcv_packet, G.sizeof_rcv_packet, 0,
(struct sockaddr *) &from, &fromlen);


if (c < 0) {
if (errno != EINTR)
bb_perror_msg("recvfrom");
continue;

}

}



We tried to debug the transmission and reception happens one time after that i am getting segv error.

please any ideas it will be helpful for debug the code.

regards
santhosh babu
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
segv debugging prakash_m80 Linux - Software 0 03-20-2009 04:10 AM
C++: thread throw C++ exception and not return from kernel (or SEGV) dk3 Programming 2 11-13-2008 09:15 AM
GVim, menus, refresh menu and SEGV Weirdofreak Linux - Software 0 11-07-2004 11:10 AM
g++ caused a SEGV! Sweet! The_Nerd Programming 2 06-23-2004 06:39 PM
g_thread_init SEGV The_Nerd Programming 1 06-20-2004 05:00 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration