Linux threads + memory + kernel2.6 + NPTL
we have our project which was running in pentium/Linux 2.4 / Linux Threads with gcc - 2.95 and glibc - 2.1.2
We are now adapting to PowerPC/ Kernel 2.6 / NPTL threads library, gcc 4.1.2 and glibc 2.5.
I face a strange problem,
Thread 1 ----> allocates a memory for a structure A in stack-------> this structure has a pointer filed which is then assigned to an array of another structute of different type B in heap.
The reference/pointer of struct A is passed to thread 2.
Thread 2----->Reads the array of data of structureB.Thread2 Calls another function in thread3 by passing the same pointer of structA.
Thread 3------>Now this thread when trying to read the structureB,Reads only the first array member correctly, when it reads from second till N, it reads from different address from the heap instead of reading from the correct addresses (which I have compared by checking inside thread2 ). So all the data of structureB other than first element in the array are empty
Function call return to thread2, when trying to read the contents of the array of structB, its Ok now.All the data are read correctly.
Problem only in Thread3.
Any possible problems in stack corruption...or thread handling due to differences in LinuxThreads and NPTL or impact of compiler version changes??
Any suggestions will be of much help..
Last edited by BalaMurali46; 10-01-2009 at 11:27 PM.
|