Sponsored Content
Top Forums Programming a strange segment fault about ltp-posix test Post 302328465 by yanglei_fage on Wednesday 24th of June 2009 11:11:42 AM
Old 06-24-2009
a strange segment fault about ltp-posix test

Hi all

In the ltp-posix test,there is a case in open_posix_testsuite\conformance\interfaces\timer_gettime\speculative/6-1.c

Quote:
#include <time.h>
#include <stdio.h>
#include <errno.h>
//#include "posixtest.h"
#define BOGUSTID 9999
int main(int argc, char *argv[])
{
timer_t tid;
struct itimerspec its;
tid = (timer_t) BOGUSTID;

if (timer_gettime(tid, &its) == -1) {
if (EINVAL == errno) {
printf("fcn returned -1 and errno==EINVAL\n");
//return PTS_PASS;
} else {
printf("fcn returned -1 but errno!=EINVAL\n");
printf("Test FAILED\n");
//return PTS_FAIL;
}
}
printf("fcn did not return -1\n");
//return PTS_PASS;
}
I run the above code,it will has a segment fault, if I modify it to below,it works well
Quote:
#include <time.h>
#include <stdio.h>
#include <errno.h>
//#include "posixtest.h"
#define BOGUSTID 9999
int main(int argc, char *argv[])
{
timer_t tid;
struct itimerspec its;
int tval=BOGUSTID;
printf("%d\n",tval);
tid = (timer_t) &tval;
printf("%d\n",tid);
if (timer_gettime(tid, &its) == -1) {
if (EINVAL == errno) {
printf("fcn returned -1 and errno==EINVAL\n");
//return PTS_PASS;
} else {
printf("fcn returned -1 but errno!=EINVAL\n");
printf("Test FAILED\n");
//return PTS_FAIL;
}
}
printf("fcn did not return -1\n");
// return PTS_PASS;
}
Anybody can tell me why?
 

8 More Discussions You Might Find Interesting

1. Programming

Segment Fault

When run it, segment fault. What is wrong? #include <stdio.h> #include <stdlib.h> const int max =20; //**************************************************** // Input Matrix //**************************************************** void inMatrixAA(int *AA, int row, int col)... (9 Replies)
Discussion started by: zhshqzyc
9 Replies

2. Shell Programming and Scripting

Strange error message with regex test...

Hi all, I have a script where i need to check the format of a string. finally, i'm waiting a "process name" and 2 numbers separated by a "," string like : "this_is_a_string.txt,1,10 should be ok" string ok : "apache.exe,1,10" string ok : "mysqld,50,0" string not ok : "ap ache,1,10"... (4 Replies)
Discussion started by: fgilain
4 Replies

3. Shell Programming and Scripting

test command looks strange...

I just ran into this today, and don't know what to make of it... if test x$SERVER = x then echo $USAGE exit 1 fi I know what everything in there does, except for the 'x' jazz... (2 Replies)
Discussion started by: jjinno
2 Replies

4. Programming

Data segment or Text segment

Hi, Whether the following piece of code is placed in the read-only memory of code (text) segment or data segment? char *a = "Hello"; I am getting two different answers while searching in google :( that's why the confusion is (7 Replies)
Discussion started by: royalibrahim
7 Replies

5. Programming

why segment fault,

I always get segment fault, why? can sb help me and modify it, I have spend on much time on #include <pthread.h> #include <stdio.h> #include <stdlib.h> #include <sys/time.h> #include <string.h> #define MAX 10 pthread_t thread; void *thread1() { int *a; int i, n; ... (1 Reply)
Discussion started by: yanglei_fage
1 Replies

6. Programming

Segment-fault handling for pthreads

Hi I have struggling a week to fix a program , in the begining i got SIGBUS , but after many attempts still the program gets SIGSEGV segment fault , In bellow i post the seg fault log + source codes. would really appreciate if experts help me to fix this segment fault error. any advice is... (2 Replies)
Discussion started by: pooyair
2 Replies

7. Programming

Segment fault for C++ program when return vector

I am trying to reverse complement DNA sequence (string) with a short c++ code using boost library. Code was compiled without any warning/error, but ran into Segmentation fault. My guess is the function to return a vector, but not sure. #include <iostream> #include <fstream> #include <string>... (14 Replies)
Discussion started by: yifangt
14 Replies

8. Programming

Segment fault related to strlen.S

Hello, This function was copied into my code, which was compiled without error/warning, but when executed there is always Segmentation fault at the end after the output (which seems correct!): void get_hashes(unsigned int hash, unsigned char *in) { unsigned char *str = in; int pos =... (7 Replies)
Discussion started by: yifangt
7 Replies
LTPCLI(1)							  BP executables							 LTPCLI(1)

NAME
ltpcli - LTP-based BP convergence layer input task SYNOPSIS
ltpcli local_node_nbr DESCRIPTION
ltpcli is a background "daemon" task that receives LTP data transmission blocks, extracts bundles from the received blocks, and passes them to the bundle protocol agent on the local ION node. ltpcli is spawned automatically by bpadmin in response to the 's' (START) command that starts operation of the Bundle Protocol; the text of the command that is used to spawn the task must be provided at the time the "ltp" convergence layer protocol is added to the BP database. The convergence layer input task is terminated by bpadmin in response to an 'x' (STOP) command. ltpcli can also be spawned and terminated in response to START and STOP commands that pertain specifically to the LTP convergence layer protocol. EXIT STATUS
0 ltpcli terminated normally, for reasons noted in the ion.log file. If this termination was not commanded, investigate and solve the problem identified in the log file and use bpadmin to restart ltpcli. 1 ltpcli terminated abnormally, for reasons noted in the ion.log file. Investigate and solve the problem identified in the log file, then use bpadmin to restart ltpcli. FILES
No configuration files are needed. ENVIRONMENT
No environment variables apply. DIAGNOSTICS
The following diagnostics may be issued to the ion.log log file: ltpcli can't attach to BP. bpadmin has not yet initialized Bundle Protocol operations. No such ltp duct. No LTP induct matching local_node_nbr has been added to the BP database. Use bpadmin to stop the LTP convergence-layer protocol, add the induct, and then restart the LTP protocol. CLI task is already started for this duct. Redundant initiation of ltpcli. ltpcli can't initialize LTP. ltpadmin has not yet initialized LTP operations. ltpcli can't open client access. Another task has already opened the client service for BP over LTP. ltpcli can't create receiver thread Operating system error. Check errtext, correct problem, and restart LTP. BUGS
Report bugs to <ion-bugs@korgano.eecs.ohiou.edu> SEE ALSO
bpadmin(1), bprc(5), ltpadmin(1), ltprc(5), ltpclo(1) perl v5.14.2 2012-05-25 LTPCLI(1)
All times are GMT -4. The time now is 07:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy