LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-30-2007, 09:08 AM   #1
nc3b
Member
 
Registered: Aug 2005
Posts: 330

Rep: Reputation: 32
Strange behavior with valgrind and threads


Hello. I came over something quite strange for me. In my program I have declared
Code:
map <int,int> client_map;
Simple. Then at some time I start a thread

Code:
pthread_t thread;
pthread_create(&thread,NULL,&main_login_thread,p);
main_login_thread is defined in another file and at the top there is
Code:
extern map <int,int> client_map;
Now, in main_login_thread, at some time I say

Code:
client_map[p->cl->sock]=p->cl->id_user;
only to find back in the program that client_map doesn't contain that. Maybe this wouldn't sound so confusing, but that's just happening when I run with valgrind
Code:
valgrind --leak-check=yes --run-libc-freeres=no
When I run it without valgrind it just goes smooth. Another thing that I tried before this was to FD_SET a socket in an fd_set . And that doesn't work either. It just feels like working with different objects:|.
Can anyone help me? Thank you.

EDIT:
Now I see I was wrong about it not modifying client_map but FD_SET still doesn't work and I am pretty sure I am not screwing up anything.

Last edited by nc3b; 12-30-2007 at 10:00 AM.
 
  


Reply



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
apache with strange behavior dimc Linux - Software 5 11-07-2004 03:58 PM
Very Strange Behavior raysr Mandriva 4 08-31-2004 02:06 PM
Strange RedHat behavior jimmmac Linux - Software 3 09-17-2003 03:03 AM
Strange Behavior andrewb758 Linux - Hardware 5 08-31-2003 02:42 PM
strange behavior abhijit Linux - General 3 07-09-2003 11:25 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:35 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
Open Source Consulting | Domain Registration