Hi there. Perl is completely new for me, anyways I got stuck with this error trying to do a simple script than must keep a connection established with a remote server. When Ping is called for the second time and Mysql server is off segmentation fault occurs.

this is the skeleton working with a local mysql server (same error):

#!/usr/bin/perl use DBI; use warnings; use strict; use Term::ReadKey; my $dsnL = "dbi:mysql:database=test;host=127.0.0.1;port=3306"; my $dbhLocal = DBI->connect($dsnL, 'root',''); $dbhLocal->{mysql_auto_reconnect} = 1; my $exit; ReadMode 4; for ( ; ; ) { if ($dbhLocal->ping()) { print "OK\n"; } else { print "FAILED\n"; } defined( $exit = ReadKey(-1) ) && $exit ne 'Q' ? last : sleep 5; } ReadMode 0; exit 0;

Output: root@debian1:/home/user# perl test.pl
OK
OK
OK
OK
Segmentation fault

Sometimes fails with *** Error in `perl': double free or corruption (!prev): 0x00000000020a89d0 ***

Someone have a idea what is happening or a way to tackle this problem?

perl -v This is perl 5, version 20, subversion 2 (v5.20.2) built for x86_64-linux-gnu-thread-multi


In reply to DBD::mysql Ping segmentation fault by RndNoob

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.