LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-29-2009, 02:22 PM   #1
strantrier
LQ Newbie
 
Registered: Dec 2009
Posts: 1

Rep: Reputation: 0
Thumbs up I am getting glibc detected error in my program submission..


my program is producing correct outputs, but while submitting iam getting the following error.


Non Preemptive Scheduling:
Following test cases failed in your program; If you would like you can correct and do "Submit solution" again:
1. Test case failed with normal inputs for function: getWaitingTime()

Error:
*** glibc detected *** output/cnonpreemptivescheduling/testnonpreemptive.exe: free(): invalid size: 0x098e21a8 ***
======= Backtrace: =========
/lib/libc.so.6[0x721b16]
/lib/libc.so.6[0x7227a2]
/lib/libc.so.6(__libc_malloc+0x7e)[0x72335e]
/lib/ld-linux.so.2[0x6a7b62]
/lib/ld-linux.so.2[0x6acafd]
/lib/ld-linux.so.2[0x6a8e36]
/lib/ld-linux.so.2[0x6ac482]
/lib/libc.so.6[0x7bf722]
/lib/ld-linux.so.2[0x6a8e36]
/lib/libc.so.6(__libc_dlopen_mode+0x55)[0x7bf8d5]
/lib/libpthread.so.0[0x83aaf7]
/lib/libpthread.so.0[0x83ac21]
/lib/libpthread.so.0(__pthread_unwind+0x51)[0x8386f1]
/lib/libpthread.so.0(pthread_detach+0x0)[0x8333c0]
output/cnonpreemptivescheduling/testnonpreemptive.exe(__gxx_personality_v0+0x1a8)[0x8048e5c]
output/cnonpreemptivescheduling/testnonpreemptive.exe[0x804962c]
output/cnonpreemptivescheduling/testnonpreemptive.exe[0x8049182]
/lib/libpthread.so.0[0x83245b]
/lib/libc.so.6(clone+0x5e)[0x789c4e]
======= Memory map: ========
002c5000-003a5000 r-xp 00000000 fd:00 23359473 /usr/lib/libstdc++.so.6.0.8
003a5000-003a9000 r-xp 000df000 fd:00 23359473 /usr/lib/libstdc++.so.6.0.8
003a9000-003aa000 rwxp 000e3000 fd:00 23359473 /usr/lib/libstdc++.so.6.0.8
003aa000-003b0000 rwxp 003aa000 00:00 0
0069b000-006b5000 r-xp 00000000 fd:00 6490409 /lib/ld-2.5.so
006b5000-006b6000 r-xp 00019000 fd:00 6490409 /lib/ld-2.5.so
006b6000-006b7000 rwxp 0001a000 fd:00 6490409 /lib/ld-2.5.so
006b9000-007f6000 r-xp 00000000 fd:00 6490410 /lib/libc-2.5.so
007f6000-007f8000 r-xp 0013d000 fd:00 6490410 /lib/libc-2.5.so
007f8000-007f9000 rwxp 0013f000 fd:00 6490410 /lib/libc-2.5.so
007f9000-007fc000 rwxp 007f9000 00:00 0
007fe000-00823000 r-xp 00000000 fd:00 6490417 /lib/libm-2.5.so
00823000-00824000 r-xp 00024000 fd:00 6490417 /lib/libm-2.5.so
00824000-00825000 rwxp 00025000 fd:00 6490417 /lib/libm-2.5.so
0082d000-00840000 r-xp 00000000 fd:00 6490412 /lib/libpthread-2.5.so
00840000-00841000 r-xp 00012000 fd:00 6490412 /lib/libpthread-2.5.so
00841000-00842000 rwxp 00013000 fd:00 6490412 /lib/libpthread-2.5.so
00842000-00844000 rwxp 00842000 00:00 0
00c38000-00c43000 r-xp 00000000 fd:00 6490432 /lib/libgcc_s-4.1.2-20080102.so.1
00c43000-00c44000 rwxp 0000a000 fd:00 6490432 /lib/libgcc_s-4.1.2-20080102.so.1
08048000-0804c000 r-xp 00000000 00:12 9780811 output/cnonpreemptivescheduling/testnonpreemptive.exe
0804c000-0804d000 rwxp 00003000 00:12 9780811 output/cnonpreemptivescheduling/testnonpreemptive.exe
098e2000-09925000 rwxp 098e2000 00:00 0
b7400000-b7421000 rwxp b7400000 00:00 0
b7421000-b7500000 ---p b7421000 00:00 0
b7559000-b755a000 ---p b7559000 00:00 0
b755a000-b7f5c000 rwxp b755a000 00:00 0
b7f69000-b7f6b000 rwxp b7f69000 00:00 0
b7f6b000-b7f6c000 r-xp b7f6b000 00:00 0 [vdso]
bfa45000-bfa5a000 rw-p bfa45000 00:00 0 [stack]

but while doing in terminal i am not getting this type of error.
and my program is

#include<stdio.h>
#include<stdlib.h>
int* getWaitingTime(int* process, int* arrivalTime, int* burstTime, int nProcess);
int main()
{
int nProcess=3;
int *process=(int *)malloc(2*nProcess);
int *arrivalTime=(int*)malloc(2*nProcess);
int *burstTime=(int*)malloc(2*nProcess);
int proc[]={1,2,3};
int aTime[]={0,4,9};
int bTime[]={6,2,1};
int *a=(int *)malloc(2*nProcess);
int i;
for(i=0;i<nProcess;i++)
{
process[i]=proc[i];
arrivalTime[i]=aTime[i];
burstTime[i]=bTime[i];
}
a=getWaitingTime(process,arrivalTime,burstTime,nProcess);
if(a!=NULL)
{
for(i=0;i<nProcess;i++)
printf("%d\t",*(a+i));
}
else
printf("The function getWaitingTime returns NULL");
free(a);
return 0;
}
int* getWaitingTime(int* process, int* arrivalTime, int* burstTime, int nProcess)
{
int i;
int sum[10];
int bur[10];
int flag[10];
int *a=(int*)malloc(2*nProcess);
int sump=*burstTime;
int sumn;
int j;
int k;
int p;
int t;
if((*(arrivalTime)!=0) ||(*burstTime<0)||(*burstTime>10))
return (NULL);
for(i=1;i<nProcess;i++)
if((*(arrivalTime+i)==0)||*(arrivalTime+i-1)>*(arrivalTime+i)||(*(burstTime+i)<0)||(*(burstTime+i)>10))
return (NULL);
for(i=0;i<nProcess;i++) {
sum[i]=*(arrivalTime+i)+*(burstTime+i);
}
bur[0]=*(burstTime);
for(i=1;i<nProcess;i++)
flag[i]=0;
flag[0]=1;
for(i=1;i<nProcess;i++)
{
if(flag[i]==0)
{
sumn=0;
for(j=i;j<nProcess;j++)
{
if(flag[j]==0){
sumn=sumn+*(arrivalTime+j);
if(sumn>sump)
break;
}
}
k=j-1;
t=*(burstTime+i);
p=i;
for(j=i+1;j<=k;j++)
{
if(flag[j]==0){
if(*(burstTime+j)<t)
{
t=*(arrivalTime+j);
p=j;
}
}
}
sump+=*(burstTime+p);
bur[p]=sump;
flag[p]=1;
if(p!=i)
i=i-1;
}
}
for(i=0;i<nProcess;i++)
{
*(a+i)=bur[i]-sum[i];
if(*(a+i)<0)
return(NULL);
}
process=a;
return (process);
}

and the program is for nonpreemptive scheduling, which prints waiting times of the arrived processess.. actually the working tool is devsquare assessments.
i am unable to find the problem with my program.
i request you to tell me how i can get rid off this error..
thank u.
 
Old 12-29-2009, 02:45 PM   #2
lieqie
LQ Newbie
 
Registered: Dec 2009
Posts: 2

Rep: Reputation: 0
if(a!=NULL)
{
for(i=0;i<nProcess;i++)
printf("%d\t",*(a+i));
}
else
printf("The function getWaitingTime returns NULL");
free(a);
return 0;
}
 
  


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
glibc detected error shibeaux Programming 1 05-13-2009 10:00 AM
*** glibc detected *** : error on my SuSE 10 box sunilvadranapu SUSE / openSUSE 1 02-20-2009 07:54 AM
Error: **** glibc detected **** nikekul Linux - Newbie 3 05-06-2008 03:01 AM
Error running a C program, glibc detected *** free(): invalid next size (normal) mesh2005 Programming 3 11-08-2006 02:52 PM
Error::*** glibc detected *** realloc(): topworld Programming 2 04-26-2006 02:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:45 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration