Hello (again :))
the following runs perfectly well on Linux, however it sigsegvs on Solaris after some loops. I have managed to trace the problem down to the pthread_getspecific call, which seems to return rubbish at some point (it does *NOT* return NULL, however the value returned is probably useless because when _parent->Notify() is called, the SIGSEGV takes place. Any ideas? Thanks!
On compilefarm Solaris machine after 10000 loop (replaced while with for) nothing appened...
Perhaps an error already fixed on CVS version (fixed recently)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have been thinking about this lately :)
Now as to the problem is concerned, I realise it always happens after 286 loops. *Always*. Could it be something that has to do with my system?
From uname -a:
SunOS myhost 5.7 Generic_106541-10 sun4u sparc SUNW,Ultra-5_10
g++: 2.95.1
Any ideas? Could it be some resource limit? Even if it is so, why does it apply sice all threads of execution Exit() normally?
Thanks!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ok I solved the problem, but I really can't understand what was wrong.
Using a Final() method with the "delete this" hack, made it work like a charm. Yet, I thought there was no need to do that -- I thought using the Exit() method was enough. Is this normal behaviour? Am I missing something?
Costas
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I removed Exit() (and also removed Final()) and the problem still existed -- sigsegv after 286 loops. Only Final() (without Exit()) seems to solve it...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ehmmm... after thinking so many...
You detach thread, so Terminate (or destructor) can wait for thread end and destruct Thread object without waiting.
So when thread exit sometime it found garbage...
Solution is code like
In MyThread::Final delete this
Thread* th = MyThread();
th->Detach();
... do other think
DO NOT DELETE th...
To found in linux I use printf for printing, remove wait in main and insert in MyThread::Run
freddy77
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello (again :))
the following runs perfectly well on Linux, however it sigsegvs on Solaris after some loops. I have managed to trace the problem down to the pthread_getspecific call, which seems to return rubbish at some point (it does *NOT* return NULL, however the value returned is probably useless because when _parent->Notify() is called, the SIGSEGV takes place. Any ideas? Thanks!
---------------- Sample code ------------------
#include <cc++/thread.h>
#ifdef CCXX_NAMESPACES
using namespace std;
using namespace ost;
#endif
#include <iostream>
class MyThread : public Thread {
public:
MyThread();
void Run();
};
MyThread::MyThread(){
;
}
void MyThread::Run(){
cout << "THREAD" << endl;
Exit();
}
int main(int argc, char *argv[]){
while (1){
MyThread m = MyThread();
m.Detach();
cout << "MAIN PROCESS" << endl;
usleep(100);
}
}
---------------- Sample code ------------------
Why not joining cc++ stuff as porting developer ??
On compilefarm Solaris machine after 10000 loop (replaced while with for) nothing appened...
Perhaps an error already fixed on CVS version (fixed recently)
I have been thinking about this lately :)
Now as to the problem is concerned, I realise it always happens after 286 loops. *Always*. Could it be something that has to do with my system?
From uname -a:
SunOS myhost 5.7 Generic_106541-10 sun4u sparc SUNW,Ultra-5_10
g++: 2.95.1
Any ideas? Could it be some resource limit? Even if it is so, why does it apply sice all threads of execution Exit() normally?
Thanks!
I forgot to mention that I already downloaded the latest CVS tree, and compiled/linked my software against it.
Ok I solved the problem, but I really can't understand what was wrong.
Using a Final() method with the "delete this" hack, made it work like a charm. Yet, I thought there was no need to do that -- I thought using the Exit() method was enough. Is this normal behaviour? Am I missing something?
Costas
Wait a moment...
Try to remove Exit() inside Run...
I removed Exit() (and also removed Final()) and the problem still existed -- sigsegv after 286 loops. Only Final() (without Exit()) seems to solve it...
Ehmmm... after thinking so many...
You detach thread, so Terminate (or destructor) can wait for thread end and destruct Thread object without waiting.
So when thread exit sometime it found garbage...
Solution is code like
In MyThread::Final delete this
Thread* th = MyThread();
th->Detach();
... do other think
DO NOT DELETE th...
To found in linux I use printf for printing, remove wait in main and insert in MyThread::Run
freddy77