linux 执行 iptables 命令出错 segmentation fault (core dumped) 的解决


linux 执行 iptables 命令出错: segmentation fault (core dumped)

systemctl status iptables.service  出错 code=dumped signal=SEGV


现象:


一台机器被强制手动关闭了,重新启动后,防火墙(iptables)不能启动,系统启动日志 /var/log/boot.log 中出现如下错误:
failed to start ipv4 firewall with iptables
failed to start ipv6 firewall with iptables
please use "systemctl status iptables.service" for detail

机器是做代理服务的,导致其他机器都不能上网了。


解决办法:

进入系统后,使用 systemctl status iptables.service 查看 iptables 状态,发现没有启动,信息如下:
Active: failed
code=dumped signal=SEGV

于是执行 iptables 命令:iptables -L

直接提示错误: segmentation fault (core dumped)

这种情况从来没有遇到过,iptables是系统软件,执行时怎么会出现段错误呢?猜测是系统强制关闭时破坏了相关文件。尝试重新安装 iptables 会不会解决问题。

首先查看本机的 iptables 的版本:rpm -qa iptables,发现是iptables-2.16-xxx.xx

于是下载了 iptables 的rpm包,即:iptables-2.16-xxx.xx.rpm

然后强制卸载 iptables 包: rpm -e --nodeps iptables-2.16-xxx.xx  这里需要加上 --nodeps 不考虑依赖,强制卸载。

卸载完毕,安装: rpm -ivh iptables-2.16-xxx.xx.rpm

安装成功后,执行 iptables 命令:iptables -L 。发现不再提示段错误了,正常了。

重启iptables,即执行命令: systemctl restart iptables.service,
查看iptables状态,即:systemctl status iptables.service。

终于正常了。



segmentation fault (core dumped)错误

03-15

[code=C/C++][/code]rn#includern#define MAXROW 100rn#define MAXCOL 100rnrntypedef struct rn char pixels[MAXROW][MAXCOL];rn int m;rn int n;rngraph;rnrnvoid create(int m,int n,graph *g);rnvoid clear(graph *g);rnvoid colorOne(char s[][MAXCOL],int x,int y,char c);rnvoid vertical_pixels(char s[][MAXCOL],int x,int y1,int y2,char c);rnvoid horizontal(char s[][MAXCOL],int x1,int x2,int y,char c);rnvoid kRectangle(char s[][MAXCOL],int x1,int y1,int x2,int y2,char c);rnvoid fRegion(graph *g,int x,int y,char c);rnvoid sName(graph *g,char *name,FILE **f);rnvoid print(FILE **f,char *name);rnrnint main()rnrngraph g;rnchar str[20];rnFILE *f=NULL;rnwhile(1)rnrn gets(str);rn if(str[0]=='X')rn break;rn switch(str[0])rn rn case 'I':rn rn create(str[2]-'0',str[4]-'0',&g);rn break;rn rn case 'C':rn rn clear(&g);rn break;rn rn case 'L':rn rn colorOne(g.pixels,str[2]-'0',str[4]-'0',str[6]);rn break;rn rn case 'H':rn rn horizontal(g.pixels,str[2]-'0',str[4]-'0',str[6]-'0',str[8]);rn break;rn rn case 'V':rn rn vertical_pixels(g.pixels,str[2]-'0',str[4]-'0',str[6]-'0',str[8]);rn break;rn rn case 'K':rn rn kRectangle(g.pixels,str[2]-'0',str[4]-'0',str[6]-'0',str[8]-'0',str[10]);rn break;rn rn case 'F':rn rn fRegion(&g,str[2]-'0',str[4]-'0',str[6]);rn break;rn rn case 'S':rn rn sName(&g,&str[2],&f);rn print(&f,&str[2]);rn break;rn rn default:rn break;rn rnrnreturn 0;rnrnrnvoid create(int m,int n,graph *g)rnrnint i,j;rng->n=n;rng->m=m;rnfor(i=1;i<=n;i++)rn for(i=1;i<=m;i++)rn g->pixels[i][j]='O';rnrnrnvoid clear(graph *g)rnrnint i,j;rnfor(i=1;i<=g->n;i++)rn for(j=1;j<=g->m;j++)rn g->pixels[i][j]='O';rnrnrnvoid colorOne(char s[][MAXCOL],int x,int y,char c)rnrns[y][x]=c;rnrnrnvoid horizontal(char s[][MAXCOL],int x1,int x2,int y,char c)rnrnint i;rnfor(i=x1;i<=x2;i++)rn s[y][i]=c;rnrnrnvoid vertical_pixels(char s[][MAXCOL],int x,int y1,int y2,char c)rnrnint i;rnfor(i=y1;i<=y2;i++)rn s[i][x]=c;rnrnrnvoid kRectangle(char s[][MAXCOL],int x1,int y1,int x2,int y2,char c)rnrnint i,j;rnfor(i=y1;i<=y2;i++)rn for(j=x1;j<=x2;j++)rn s[i][j]=c; rnrnrnvoid fRegion(graph *g,int x,int y,char c)rnrnint i,j;rnchar col;rncol=g->pixels[y][x];rnfor(i=1;i<=g->n;i++)rn for(j=1;j<=g->m;j++)rn rn if(g->pixels[i][j]==col)rn g->pixels[i][j]=c;rn rnrnrnvoid sName(graph *g,char *name,FILE **f)rnrnint i,j;rn*f=fopen(name,"w");rnif(*f == NULL)rnrn return;rnrnfor(i=1;i<=g->n;i++)rnrn for(j=1;j<=g->m;j++)rn rn fputc(g->pixels[i][j],*f);rn rn fputc('\n',*f);rnrnfclose(*f);rnrnrnvoid print(FILE **f, char *name)rnrnprintf("%s\n",name);rn*f=fopen(name,"r");rnif(*f == NULL)rnrn return;rnrnprintf("%c",fgetc(*f));rnfclose(*f);rnrn

线程 Segmentation fault (core dumped)

02-13

小弟初学linux, 根据书上写了个小程序rn#include rn#include rn#include rn#include rnrnvoid printids(const char *);rnvoid *start(void *);rnrnpthread_t ntid;rnrnvoid printids(const char *s)rnrn pid_t pid;rn pthread_t tid;rn rn pid = getpid();rn tid = pthread_self();rn printf("%s : pid is %u, tid is %u (0x%x)\n", s, pid, tid, tid);rnrnrnvoid *start(void *p)rnrn printids("new thread");rnrn return ((void *)0);rnrnrnvoid main()rnrn int err;rnrn err = pthread_create(&ntid, NULL, start(NULL), NULL);rn if(err != 0)rn rn printf("error, cann't create new thread");rn exit(0);rn rn printids("main thread");rn printf("start sleep\n");rn sleep(5);rn printf("end \n");rn exit(0);rnrnrn编译后执行,结果如下rn[root@localhost test]# gcc thread.c -o thread -lpthreadrn[root@localhost test]# ./threadrnnew thread : pid is 2442, tid is 4008711936 (0xeef01700)rnmain thread : pid is 2442, tid is 4008711936 (0xeef01700)rnstart sleeprnSegmentation fault (core dumped)rnrn当我把程序中 sleep(5) 注释掉后编译执行正常,结果为rn[root@localhost test]# gcc thread.c -o thread -lpthreadrn[root@localhost test]# ./threadrnnew thread : pid is 2830, tid is 2600584960 (0x9b01c700)rnmain thread : pid is 2830, tid is 2600584960 (0x9b01c700)rnstart sleeprnend rnrn我不明白程序哪里出错了rnrn而且 main thread的线程id,和新创建线程new thread 的线程id 相同, 按说应该不同的rnrn我的系统是centos6.2,gcc version 4.4.6rnrn请高手指点

linux C 错误 :segmentation fault(core dumped)

05-12

[code=c]rn#includern#includern#includern#include rn//#include rn#define N 6rnenum STATEready, run, finishSTATE;rnrn// 待插入就绪队列的进程数据rnint id[N] = 0, 1, 2, 3, 4, 5 ;rnint priority[N] = 9, 38, 17, 2, 7, 18 ;rnint cpuTime[N] = 0, 0, 0, 0, 0, 0 ;rnint allTime[N] = 3, 2, 3, 6, 1, 3 ;rn rntypedef struct PCBrn int pid;rn int priority;rn int cpuTime;rn int allTime; rn int state;rn struct PCB *next;rnPCB;rntypedef structrn PCB *head;rn PCB *tail;rn PCB *maxPriority;rnlinkQueue;rnrnlinkQueue readyQueue;rnrnvoid initQueue()rn int maxm = -1;rn int i;rn PCB *head, *tail, *p;rn readyQueue.head = readyQueue.tail = (PCB *)malloc(sizeof(PCB));rn head->next=NULL;rn for(i=0;ipid = id[i];rn p->priority = priority[i];rn p->cpuTime = cpuTime[i];rn p->allTime = allTime[i];rn p->state = ready;rn p->next = NULL;rn readyQueue.tail->next = p;rn readyQueue.tail = p;rn if(priority[i] > maxm)rn readyQueue.maxPriority = p;rn maxm = priority[i];rn rnrn rnrn return;rnrnrn/* 查看正在运行进程的信息 */rnvoid runningProcess(PCB *p)rn printf("-------------------------------Running--------------------------------\n");rn printf("Pid=%d\tPriority=%d\tCpuTime=%d\tAllTime=%d\tState=running\n", p->pid, p->priority, p->cpuTime, p->allTime);rn printf("----------------------------------------------------------------------\n");rn return; rnrnrnrn/* 查看就绪队列的信息 */rnvoid readyQueCheck()rn PCB *p = readyQueue.head->next;rn// printf("\n%d\n", readyQueue.tail->pid);rn printf("-------------------------------Ready----------------------------------\n");rn if(p == NULL) rn printf("Ready queue is empty!\n");rn while(p != NULL)rn printf("Pid=%d\tPriority=%d\tCpuTime=%d\tAllTime=%d\tState=ready\n", p->pid, p->priority, p->cpuTime, p->allTime);rn p = p->next;rn rn printf("----------------------------------------------------------------------\n");rnrnrnrnvoid enQueue(PCB *p)rn readyQueue.tail->next = p;rn readyQueue.tail = p;rn p->next = NULL;rn return;rnrnrn/* 让指定的进程出列 */rnvoid popQueue(PCB *p)rn if(readyQueue.head->next != NULL)rn PCB *temp = readyQueue.head;rn while(temp!=NULL)rn if(temp->next == p)rn temp->next = p->next;rn p->next = NULL;rn if(temp->next==NULL)rn readyQueue.tail = temp;rn return; rn rn temp = temp->next; rn rn printf("Process not found!\n");rn elsern printf("Queue is empty!\n");rn rn return;rnrnrn/* 更新就绪队列最大优先权进程 */rnvoid updateMaxPriority()rn PCB *p;rn int maxm = -1;rn p = readyQueue.head->next;rn while(p != NULL)rn if(p->priority > maxm)rn readyQueue.maxPriority = p;rn maxm = p->priority;rn rn p = p->next;rn rn return;rnrnrnrnrnvoid timeSlice()rn popQueue(readyQueue.maxPriority);rn PCB *p = readyQueue.head->next;rn runningProcess(readyQueue.maxPriority);rn readyQueCheck();rn readyQueue.maxPriority->priority = readyQueue.maxPriority->priority-3;rn readyQueue.maxPriority->cpuTime++;rn readyQueue.maxPriority->allTime--;rn readyQueue.maxPriority->state = run;rn while(p != NULL)rn p->priority++;rn p = p->next;rn rn if(readyQueue.maxPriority->allTime != 0)rn enQueue(readyQueue.maxPriority); rn else rn free(readyQueue.maxPriority);rn rn updateMaxPriority();rnrnrnrnrn/* 检查队列是否为空 */rnint isEmpty(linkQueue q)rn if(q.head->next == NULL)rn return 1;rn return 0;rn rnrnint main()rnrn int slices=0;rn initQueue();rn printf("CPU RUNNING:\n");rn// Sleep(500);rn while(!isEmpty(readyQueue))rn slices++;rn timeSlice();rn// Sleep(300);rn rn printf("All processes finished! Using %d timelices\n", slices);rn return 0;rnrn[/code]rn程序功能:模拟动态优先权算法rn在windows下能正常运行,在centos6.6下就报错 :segmentation fault(core dumped)了,调了一天都不知道是怎么回事,求大神帮帮忙,

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试