Scalars Leaked and Segmentation Fault

A

AMLiapunov

Hi all,
this is my first post on this group.
I'm developing a distribuited application with perl 5.8.7 and ithreads.
I'm experiencing scalars leaked problem and segmentation fault too.
Each module of the code uses strict and warnings.
As you can imagine it is very difficult to perform a debug of the code
as i've no debug informations from the interpreter.

Anyone could share opinions or comments.

Thanks
 
Z

zentara

Hi all,
this is my first post on this group.
I'm developing a distribuited application with perl 5.8.7 and ithreads.
I'm experiencing scalars leaked problem and segmentation fault too.
Each module of the code uses strict and warnings.
As you can imagine it is very difficult to perform a debug of the code
as i've no debug informations from the interpreter.

Anyone could share opinions or comments.

You should show a minimum example of code, but in general......

You can get those scalars leaked error messages IIRC, if you
do something like let a thread(s) die before joining. I guess it means
that there are still refs to some variable used in the thread, but
the thread no longer exists. Like I said IIRC....I remember seeing
a few of those errors, last time I played with the newer threads in
Gtk2, where you can launch threads after a gui was created.
I have some code which will produce those errors, but really havn't
found the cause.

The only way I have found, to safely run threads, is to create all
threads, before you create the main part of your script. That way,
they don't share any code, (and possibly refs).
Also I am guessing it is a harmless error, as long as your memory use
is not rising, much like the common "a thread exited while others were
running". The warnings may be annoying, but are harmless.

The segfault is more serious, and most likely comes from shraing objects
across threads, or creating a thread after the main thread already has
an object ( which gets copied ) and raises havoc, ( google for objects
and thread safety).

In case you are running the threads from a GUI, the latest Gtk2 libs
have some extra thread-safety included, where you start the script with
##############################################
use Gtk2 qw/-init -threads-init/;

#this line causes the warning, but dosn't die
die "Glib::Object thread safetly failed"
unless Glib::Object->set_threadsafe (TRUE);
##############################################

Under carefully controlled conditions, this lets you launch threads
after the GUI is created, and you control when you enter and leave a
thread with
Gtk2::Gdk::Threads->enter;
Gtk2::Gdk::Threads->leave;


But even with those features, you can still get scalars-leaked errors
when you spawn-and-join threads in a running program, but they seem
harmless and don't affect memory usage. In my tests, they seem to happen
when I join a thread, which was created after the main script was up and
running. Like I said, I'm guessing that the new thread got a useless
copy of some variable from main, and the ref count went up, but when the
thread was joined, it was cleaned up properly.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top