On Sat, 28 Oct 2017 01:09:59 -0700, mt1...@gmail.com wrote:
> Hi @Zoffix Znet
> 
> Do you have any pointers or howto's to write thread-save code?
> Otherwise
> I'd remove all of the promises. It gave some other problems in the
> past.
> Regards
> Marcel
> > On Thu, 26 Oct 2017 06:04:51 -0700, alex.jakime...@gmail.com wrote:
> >> FWIW, when toasting I observed double free or corruption when
> >> installing both
> >> BSON and MongoDB modules. The issue is really there, and should be
> >> reproducible
> >> by just running the tests. That said, I've been running BSON tests
> >> locally in a
> >> loop for hours with no luck.
> > I can repro it easily on by Ubuntu box. Golfed it down to the
> > attached code running in BSON repo[^1]
> > checkout with `while perl6 -Ilib t/300-document.t; do true; done`. I
> > get double-free errors as well as
> > occasional failing tests.
> >
> > Briefly glancing at the guts of the module and seeing all the
> > Promises created left, right, and center,
> > it wouldn't surprise me if this issue is due to the BSON module doing
> > thread-unsafe things somewhere and
> > not an issue in rakudo.
> >
> > [1] https://github.com/MARTIMM/BSON
> >


I'm the wrong person to ask.

Mutating some object (e.g an array) from multiple threads is one of the things:

    Crash:
    $ perl6 -e 'my @a; await ^10000 .map: {start @a.push: rand}; say @a.elems'
    *** Error in `/home/zoffix/.rakudobrew/moar-2017.09/install/bin/moar': 
realloc(): invalid next size: 0x00007fcb440ca050 ***

    Wrong value:
    $ perl6 -e 'my $a; await ^10000 .map: {start $a++}; say $a'
    9956

Reply via email to