ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
From what you have said it is impossible for anyone to tell you what the problem is.
A segmentation fault occurs when a program is trying to access memory it is not permitted to access. There are many ways in which this can happen.
Did you write the program yourself?
Did you compile it from provided source code?
Did you install it from a package manager?
To get a meaningful answer from this forum we would need to know about the lines in error. If you don't have the source then I suspect that a more productive approach would be to contact the developers.
You will need to compile it with debugging information, which language is used? C, C++, another? How did you compile the code with gcc, make?
For a C compiler you will want to use the -g flag in gcc
For make maybe the following will help: make debug=yes
Once it is compiled with debugging information then you need to use a debugger to tell you where the problem occurs. Maybe your friend can help you with all of this.
[root@miru zoneIT]# make debug=yes
gcc -ggdb rsa.o communication.o scanner.o zoneIT.o directory.o linkedlist.o -o z oneIT -lbluetooth -lm -lpthread just this was displayed
i told in my last post that i got this from a friend of mine who is no longer available n i want this to function properly. its kind of urgent.
[root@miru zoneIT]# ./zoneIT
zoneIT Access Point application Usage: zoneIT -d 500 -p 1 (default use) -d directory_size500Scanning all BT devices ...
found 00:0A:D9:60:E3:6C
no of threads running is 0
The bluetooth address 00:0A:D9:60:E3:6C is not found, trying to access...
no of threads running is 1
Completed screening all scanned devices
The address connect from : 00:00:00:00:00:00
The address to connect is: 6C:E3:60:D9:0A:00
Can't connect to 00:0A:D9:60:E3:6C, Operation already in progress(114)
Waiting for threads to finish, 1 threads are runnning.Waiting for threads to finish, 0 threads are runnning.Completed access control procedures 0 times.
*****************************************************************************************
Are you prepared to post the source code? Please do not just paste pages and pages of code into the forums - I'm asking the question if you are prepared to. Before answering you should probably review license terms for the software - is it legal to post the code in public?
If it's open source and that you can post the code, and you do post the code, you may find someone who will help you debug it. If not, I would recommend hiring a programmer with relevant experience to do it.
well i have said earlier that it is my friends project n now i need it to work! so i m pasting the link here of the whole prog. it is in ".rar" format n u hav to extract the files first:
I thought I would have a go at this but I think I'm out of my depth.
valgrind output
Code:
Invalid read of size 4
==27848== at 0x1B969947: pthread_setschedparam (in /lib/tls/libpthread-2.3.5.so)
==27848== by 0x804A8C0: scanAllDevices (zoneIT.c:240)
==27848== by 0x804A6C1: main (zoneIT.c:139)
==27848== Address 0x48 is not stack'd, malloc'd or (recently) free'd
==27848==
==27848== Process terminating with default action of signal 11 (SIGSEGV)
==27848== Access not within mapped region at address 0x48
==27848== at 0x1B969947: pthread_setschedparam (in /lib/tls/libpthread-2.3.5.so)
==27848== by 0x804A8C0: scanAllDevices (zoneIT.c:240)
==27848== by 0x804A6C1: main (zoneIT.c:139)
offending function...
Code:
int scanAllDevices(){
//priority doesn't matter much when using SCHED_OTHER policy
extern struct sched_param param1;
extern struct sched_param param2;
memset(¶m1,0,sizeof(param1));
memset(¶m2,0,sizeof(param2));
int priority1=4;
int priority2=4;
int count ;
int policy1,policy2,policy3;
int ret =0;
// thread schedule
param1.sched_priority = priority1;
param2.sched_priority = priority2;
// set detatchable attribute to scanner
pthread_attr_t attr1;
pthread_attr_init(&attr1);
pthread_attr_setdetachstate(&attr1, PTHREAD_CREATE_JOINABLE);
pthread_t scanner;
memset(&scanner,0,sizeof(scanner));
policy1 = SCHED_FIFO;
policy2 = SCHED_OTHER;
policy3 = SCHED_RR;
/******** (zoneIT.c:139) below as per ***************/
ret += pthread_setschedparam(scanner, policy2, ¶m1);
ret += pthread_create(&scanner, &attr1, scan_all_dev, arg);
ret += pthread_join(scanner, NULL);
return ret;
}
re
Quote:
Address 0x48 is not stack'd, malloc'd or recently free'd
How can i trace this meory address back to the offending variable in the source code???
Okay it looks af if the offending line is 240 in the file zoneIT.c
Code:
==27848== by 0x804A8C0: scanAllDevices (zoneIT.c:240)
==27848== by 0x804A6C1: main (zoneIT.c:139)
==27848== Address 0x48 is not stack'd, malloc'd or (recently) free'd
zoneIT.c:240 This means file zoneIT.c line number 240
from zoneIT.c:139 you can tell where the function scanAllDevices() was called from, which is sometimes useful. (line 139)
is infact zoneIT.c:240.
Its the call to pthread_setschedparam()
Code:
ret += pthread_setschedparam(scanner, policy2, ¶m1);
I have looked at the parameters with gdb and they seem to be initialised ok?!
Cybil001
You just need to be patient to see if someone can debug this code.
Even if I/we find the problem to what is causing this initial crash there may be other bugs else where!??
I'm no expert on threads, but my guess is that the thread (scanner) hasn't been set up properly. What might be required is:
Code:
ret += pthread_create(&scanner, &attr1, scan_all_dev, arg);
ret += pthread_setschedparam(scanner, policy2, ¶m1);
As I understand it pthread_setschedparam() is expecting a valid thread ID, which pthread_create() establishes. So a blind stab in the dark would be to switch those two lines around. Sorry not very convincing but might be worth a shot.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.