vishi has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I am using the module Expect.pm to automate tasks by sending commands to a remote host. All these days, expect was behaving normally, but all of a sudden, my programs have started to throw a "Memory fault" error.

When I ran the code in debugging mode, I found out that as soon as I do a

my $sshAuth = Expect->spawn("ssh $User\@$source_DB");

The program terminates with a Memory fault. I am not sure what's causing the issue. How do I go about figuring out whether:

Is there some way I can "trap" this to find the root cause?

Replies are listed 'Best First'.
Re: Expect.pm causing Memory fault?
by i5513 (Pilgrim) on Aug 04, 2011 at 14:26 UTC
    Hello

    See what "free" command says about free memory, and what "ulimit" command says about limits has your user

    But, wait! Which is the exact message which your application/perl give you ?

    Maybe it is not a limit / free memory available problem

    In your situation, I surely would test an "empty program" with only your sentence:

    #!/usr/bin/perl use strict; use Expect; my $user="user"; my $source_DB="source"; Expect->spawn("ssh $User\@$source_DB"); Expect->interact;

    And see if it is the root cause .. (I doubt it)

    Maybe google has more hints

    Regards,

      I did that .. and a regular Perl program runs fine. When I use the module, it goes crazy. Another development is that I cannot use the debugger now - when I run the program in the debugging mode, I do not get the debugger prompt. Instead, it hangs and I see that CPU utilization hits 100%. I have to forcibly stop and kill the process (Ctrl Z & kill -9 PID).

      What's surprising is that other programs that use the same module are running fine. I'm not sure what's so special about this piece of code that's making Perl angry that it throws a "Memory fault" at me.