develooper Front page | perl.perl6.compiler | Postings from May 2018

[perl #133162] Problem with sample socket code: core dump frommalloc failure and memory corruption

From:
Ben Sauvin
Date:
May 4, 2018 22:00
Subject:
[perl #133162] Problem with sample socket code: core dump frommalloc failure and memory corruption
Message ID:
rt-4.0.24-30051-1525064676-1024.133162-82-0@perl.org
# New Ticket Created by  Ben Sauvin 
# Please include the string:  [perl #133162]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=133162 >


I'm trying to run this code:

my $n;
await IO::Socket::Async.connect('127.0.0.1', 5000).then( -> $promise {
    given $promise.result {
        react {
            whenever .Supply(:enc("utf8-c8")).lines -> $v {
#            whenever .Supply() -> $v {
                printf "%d %s\n", ++$n, $v;
#                $v.print;
#                done;
            }
        }
        ## .close;
    }
});

In my particular case, the input from port 5000 is RAW IRC lines relayed
through a socket from a script running under my client; live input. The
above program terminates abnormally with the error message after a few
thousand lines:

*** Error in `/usr/local/bin/moar': malloc(): memory corruption:
0x00007f133c158840 ***

One of the guys in #perl6 on Freenode reports:

this works for reproducing the leak: yes | pv -L 30m | netcat -l -p 5000
127.0.0.1

He also reports rapidly increasing memory consumption before the OOM killer
gets it, and that even after stopping the 'yes', his line continues
producing output. He's suggested this might be a memory leak. Mine was a
much longer running experience (usually), with no increase in CPU or MEM as
reported by htop, but I *have* noticed that whole batches of lines are
printed without line numbers.

I'm running Rakudo Star version 2018.01 built on MoarVM version 2018.01,
implementing Perl 6.c, on an Ubuntu 16.04 machine (64-bit) with
distro-supplied kernel, libc and libraries, with uname -a:

Linux kubuntu 4.4.0-122-generic #146-Ubuntu SMP Mon Apr 23 15:34:04 UTC
2018 x86_64 x86_64 x86_64 GNU/Linux.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About