perl调用mysql时出现的错误——*** glibc detected *** perl: double free or corruption (!prev):


最近更新了一次perl,覆盖了原来系统自带的perl(从10.1到14.4).更新后重新安装了所需的模块DBI和DBD::msyql,但现在每次用perl调用mysql的时候,SQL语句可以执行成功,但就是会报错。脚本如下:

注:系统为CentOS 6.4,尝试了很多方法和各个perl版本都不行,这个脚本在windows下运行正常。


 ###################
#执行的脚本
    #!/usr/bin/perl  
    use 5.10.1;  
    use DBI;  
    my $user = 'root';  
    my $password = 'root';  
    my $dsn = 'DBI:mysql:database=user;host=192.168.1.93;port=3306';  

    my $dbh = DBI->connect ($dsn, $user, $password, { RaiseError => 1,    AutoCommit => 0 })  ; #  
    $dbh->do ("DROP TABLE IF EXISTS test") ;  
    $dbh->disconnect();  
#####################

具体报错如下:


 *** glibc detected *** perl: double free or corruption (!prev): 0x00000000020a4750 ***
======= Backtrace: =========  
/lib64/libc.so.6[0x323fc760e6]  
/lib64/libc.so.6[0x323fc78c13]  
/usr/lib/perl5/site_perl/5.14.4/x86_64-linux/auto/DBD/mysql/mysql.so(mysql_db_destroy+0x3c)[0x7f303421c80c]  
/usr/lib/perl5/site_perl/5.14.4/x86_64-linux/auto/DBD/mysql/mysql.so(XS_DBD__mysql__db_DESTROY+0x1e4)[0x7f3034225144]  
/usr/lib/perl5/site_perl/5.14.4/x86_64-linux/auto/DBI/DBI.so(XS_DBI_dispatch+0x16d4)[0x7f303464bb54]  
perl(Perl_pp_entersub+0x6a1)[0x48d6a1]  
perl(Perl_call_sv+0x60b)[0x4300cb]  
perl(Perl_sv_clear+0x53b)[0x496edb]  
perl(Perl_sv_free2+0x36)[0x4975a6]  
perl[0x479615]  
perl(Perl_mg_free+0x23)[0x4796e3]  
perl(Perl_sv_clear+0x171)[0x496b11]  
perl(Perl_sv_free2+0x36)[0x4975a6]  
perl(Perl_leave_scope+0x11c4)[0x4b9f04]  
perl(Perl_pp_leave+0xf9)[0x48db79]  
perl(Perl_runops_standard+0x13)[0x48bc63]  
perl(perl_run+0x288)[0x430828]  
perl(main+0x10c)[0x41c15c]  
/lib64/libc.so.6(__libc_start_main+0xfd)[0x323fc1ecdd]  
perl[0x41bf89]  
======= Memory map: ========  
00400000-0054b000 r-xp 00000000 08:02 42753216                           /usr/bin/perl  
0074a000-0074e000 rw-p 0014a000 08:02 42753216                           /usr/bin/perl  
0074e000-0074f000 rw-p 00000000 00:00 0 
01e15000-020e2000 rw-p 00000000 00:00 0                                  [heap]  
323f400000-323f420000 r-xp 00000000 08:02 2097598                        /lib64/ld-2.12.so  
323f61f000-323f620000 r--p 0001f000 08:02 2097598                        /lib64/ld-2.12.so  
323f620000-323f621000 rw-p 00020000 08:02 2097598                        /lib64/ld-2.12.so  
323f621000-323f622000 rw-p 00000000 00:00 0 
323f800000-323f883000 r-xp 00000000 08:02 2097612                        /lib64/libm-2.12.so  
323f883000-323fa82000 ---p 00083000 08:02 2097612                        /lib64/libm-2.12.so  
323fa82000-323fa83000 r--p 00082000 08:02 2097612                        /lib64/libm-2.12.so  
323fa83000-323fa84000 rw-p 00083000 08:02 2097612                        /lib64/libm-2.12.so  
323fc00000-323fd8a000 r-xp 00000000 08:02 2097599                        /lib64/libc-2.12.so  
323fd8a000-323ff89000 ---p 0018a000 08:02 2097599                         /lib64/libc-2.12.so  
323ff89000-323ff8d000 r--p 00189000 08:02 2097599                        /lib64/libc-2.12.so  
323ff8d000-323ff8e000 rw-p 0018d000 08:02 2097599                        /lib64/libc-2.12.so  
323ff8e000-323ff93000 rw-p 00000000 00:00 0 
3240000000-3240002000 r-xp 00000000 08:02 2097605                        /lib64/libdl-2.12.so  
3240002000-3240202000 ---p 00002000 08:02 2097605                        /lib64/libdl-2.12.so  
3240202000-3240203000 r--p 00002000 08:02 2097605                        /lib64/libdl-2.12.so  
3240203000-3240204000 rw-p 00003000 08:02 2097605                        /lib64/libdl-2.12.so  
3240400000-3240417000 r-xp 00000000 08:02 2097600                        /lib64/libpthread-2.12.so  
3240417000-3240617000 ---p 00017000 08:02 2097600                        /lib64/libpthread-2.12.so  
3240617000-3240618000 r--p 00017000 08:02 2097600                        /lib64/libpthread-2.12.so  
3240618000-3240619000 rw-p 00018000 08:02 2097600                        /lib64/libpthread-2.12.so  
3240619000-324061d000 rw-p 00000000 00:00 0 
3240c00000-3240c07000 r-xp 00000000 08:02 2097601                        /lib64/librt-2.12.so  
3240c07000-3240e06000 ---p 00007000 08:02 2097601                        /lib64/librt-2.12.so  
3240e06000-3240e07000 r--p 00006000 08:02 2097601                        /lib64/librt-2.12.so  
3240e07000-3240e08000 rw-p 00007000 08:02 2097601                        /lib64/librt-2.12.so  
324ac00000-324ac07000 r-xp 00000000 08:02 2097616                        /lib64/libcrypt-2.12.so  
324ac07000-324ae07000 ---p 00007000 08:02 2097616                        /lib64/libcrypt-2.12.so  
324ae07000-324ae08000 r--p 00007000 08:02 2097616                        /lib64/libcrypt-2.12.so  
324ae08000-324ae09000 rw-p 00008000 08:02 2097616                        /lib64/libcrypt-2.12.so  
324ae09000-324ae37000 rw-p 00000000 00:00 0 
324b000000-324b05d000 r-xp 00000000 08:02 2097615                        /lib64/libfreebl3.so  
324b05d000-324b25c000 ---p 0005d000 08:02 2097615                        /lib64/libfreebl3.so  
324b25c000-324b25d000 r--p 0005c000 08:02 2097615                        /lib64/libfreebl3.so  
324b25d000-324b25e000 rw-p 0005d000 08:02 2097615                        /lib64/libfreebl3.so  
324b25e000-324b262000 rw-p 00000000 00:00 0 
324b800000-324b816000 r-xp 00000000 08:02 2097620                        /lib64/libgcc_s-4.4.7-20120601.so.1  
324b816000-324ba15000 ---p 00016000 08:02 2097620                        /lib64/libgcc_s-4.4.7-20120601.so.1  
324ba15000-324ba16000 rw-p 00015000 08:02 2097620                        /lib64/libgcc_s-4.4.7-20120601.so.1  
324c800000-324c8e8000 r-xp 00000000 08:02 42743290                       /usr/lib64/libstdc++.so.6.0.13  
324c8e8000-324cae8000 ---p 000e8000 08:02 42743290                       /usr/lib64/libstdc++.so.6.0.13  
324cae8000-324caef000 r--p 000e8000 08:02 42743290                       /usr/lib64/libstdc++.so.6.0.13  
324caef000-324caf1000 rw-p 000ef000 08:02 42743290                       /usr/lib64/libstdc++.so.6.0.13  
324caf1000-324cb06000 rw-p 00000000 00:00 0 
3250400000-3250402000 r-xp 00000000 08:02 2097610                        /lib64/libutil-2.12.so  
3250402000-3250601000 ---p 00002000 08:02 2097610                        /lib64/libutil-2.12.so  
3250601000-3250602000 r--p 00001000 08:02 2097610                        /lib64/libutil-2.12.so  
3250602000-3250603000 rw-p 00002000 08:02 2097610                        /lib64/libutil-2.12.so  
3250800000-3250816000 r-xp 00000000 08:02 2097204                        /lib64/libnsl-2.12.so  
3250816000-3250a15000 ---p 00016000 08:02 2097204                        /lib64/libnsl-2.12.so  
3250a15000-3250a16000 r--p 00015000 08:02 2097204                        /lib64/libnsl-2.12.so  
3250a16000-3250a17000 rw-p 00016000 08:02 2097204                        /lib64/libnsl-2.12.so  
3250a17000-3250a19000 rw-p 00000000 00:00 0 
7f3033a3b000-7f3033a47000 r-xp 00000000 08:02 2097182                    /lib64/libnss_files-2.12.so  
7f3033a47000-7f3033c47000 ---p 0000c000 08:02 2097182                    /lib64/libnss_files-2.12.so  
7f3033c47000-7f3033c48000 r--p 0000c000 08:02 2097182                    /lib64/libnss_files-2.12.so  
7f3033c48000-7f3033c49000 rw-p 0000d000 08:02 2097182                    /lib64/libnss_files-2.12.so  
7f3033c49000-7f3033f94000 r-xp 00000000 08:02 42752391                   /usr/lib64/libmysqlclient.so.18.1.0  
7f3033f94000-7f3034194000 ---p 0034b000 08:02 42752391                   /usr/lib64/libmysqlclient.so.18.1.0  
7f3034194000-7f303420c000 rw-p 0034b000 08:02 42752391                   /usr/lib64/libmysqlclient.so.18.1.0  
7f303420c000-7f3034211000 rw-p 00000000 00:00 0 
7f3034211000-7f303422b000 r-xp 00000000 08:02 48234759                   /usr/lib/perl5/site_perl/5.14.4/x86_64-linux/auto/DBD/mysql/mysql.so  
7f303422b000-7f303442a000 ---p 0001a000 08:02 48234759                   /usr/lib/perl5/site_perl/5.14.4/x86_64-linux/auto/DBD/mysql/mysql.so  
7f303442a000-7f303442d000 rw-p 00019000 08:02 48234759                   /usr/lib/perl5/site_perl/5.14.4/x86_64-linux/auto/DBD/mysql/mysql.so  
7f303442d000-7f3034437000 r-xp 00000000 08:02 48105104                   /usr/lib/perl5/site_perl/5.14.4/x86_64-linux/auto/List/Util/Util.so  
7f3034437000-7f3034636000 ---p 0000a000 08:02 48105104                   /usr/lib/perl5/site_perl/5.14.4/x86_64-linux/auto/List/Util/Util.so  
7f3034636000-7f3034637000 rw-p 00009000 08:02 48105104                   /usr/lib/perl5/site_perl/5.14.4/x86_64-linux/auto/List/Util/Util.so  
7f3034637000-7f3034655000 r-xp 00000000 08:02 47975908                   /usr/lib/perl5/site_perl/5.14.4/x86_64-linux/auto/DBI/DBI.so  
7f3034655000-7f3034854000 ---p 0001e000 08:02 47975908                   /usr/lib/perl5/site_perl/5.14.4/x86_64-linux/auto/DBI/DBI.so  
7f3034854000-7f3034855000 rw-p 0001d000 08:02 47975908                   /usr/lib/perl5/site_perl/5.14.4/x86_64-linux/auto/DBI/DBI.so  
7f3034855000-7f303a6e6000 r--p 00000000 08:02 42733014                   /usr/lib/locale/locale-archive  
7f303a6e6000-7f303a6eb000 rw-p 00000000 00:00 0 
7f303a701000-7f303a703000 rw-p 00000000 00:00 0 
7fff22e8a000-7fff22e9f000 rw-p 00000000 00:00 0                          [stack]  
7fff22fff000-7fff23000000 r-xp 00000000 00:00 0                          [vdso]  
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]  
^CAborted (core dumped)#最后这句是按ctrl+C终止了程序

这个问题已经困扰我三天了,求大神帮忙!

perl Linux mysql

时が走り出す 11 years, 9 months ago

从Dump上来看,指针二次释放发生在0x00000000020a4750,看内存地址隐射指针此时指向的范围在


 01e15000-020e2000 rw-p 00000000 00:00 0                                  [heap]

可以推断跟DBI.so等下面一系列的依赖没有关系,是用户空间的错误,这种堆错误建议的可能就是新的perl和老的MySQL-devel的glibc不兼容导致的,glibc不兼容常常导致堆这里出问题

mantou answered 11 years, 9 months ago

Your Answer