Re: Scalars Leaked and Segmentation Fault



On Tue, 21 Feb 2006 12:53:19 GMT, AMLiapunov <liapunov@xxxxxxxx> wrote:

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.





--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
.



Relevant Pages

  • Re: Possible bug in Exchange GUI (Exchange System Manager.msc)
    ... Connection settings for SMTP server. ... Script that I used for changing settings and reading them ... And GUI ...
    (microsoft.public.exchange.admin)
  • Re: how do you test GUI functionality?
    ... (CART; Classic is the name of the application). ... I have one script which tests handing off control from one GUI to ... # Returns a script to push a specified button in a GUI. ...
    (comp.lang.tcl)
  • Re: GUI v Script
    ... > I maintain an old system which has a locally developed script interface. ... > faster with a CLI than a GUI, particularly if the GUI is like Windows, ... with both programming skills and subject matter knowledge. ...
    (comp.object)
  • Possible bug in Exchange GUI (Exchange System Manager.msc)
    ... I’m writing this because I think I found one small bug in Exchange GUI. ... Connection settings for SMTP server. ... Manager.msc on first server and iis.msc on second server. ... First I used script to target settings for SmtpSvc/1 ...
    (microsoft.public.exchange.admin)
  • Re: Monitor GUI
    ... I currently have a simple little Perl script whose job is to listen on ... a TCL window. ... red when we've gotten an error message. ... GUI never gets created. ...
    (comp.lang.perl.tk)

Loading