发表文章

[C#] 32位系统上的一班轮镦 valgrind One liner upsetting valgrind on 32 bit system[MoarVM]

dogbert17 2017-10-9 58

下面的代码段导致 valgrind 抱怨无效的读取:

$sh = <a>.SetHash;
for $sh.values { $_ = 0; $_ = 1 }

# valgrind 运行上面的代码

dogbert@dogbert-VirtualBox ~/repos/rakudo $ ./perl6-valgrind-m  -e 'my $sh = <a>.SetHash; for $sh.pairs { .value = 0; .value = 1 }'
================================================================================================
This is Rakudo Perl 6 running in valgrind, a tool for debugging and profiling programs.
Running a program in valgrind usually takes *a lot* more time than running it directly,
so please be patient.
This Rakudo version is 2017.05.91.gf.2.fca.0.c.8.c built on MoarVM version   2017.05.24.gd.86.a.35.b.6,
running on ubuntu (14.04.3.LTS.Trusty.Tahr) / linux (3.19.0.32.generic)
------------------------------------------------------------------------------------------------
==13508== Memcheck, a memory error detector
==13508== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==13508== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==13508== Command: /home/dogbert/repos/rakudo/install/bin/moar --execname=./perl6-ugga --libpath=/home/dogbert/repos/rakudo/install/share/nqp/lib --libpath=/home/dogbert/repos/rakudo/install/share/nqp/lib --libpath=. /home/dogbert/repos/rakudo/perl6.moarvm --nqp-lib=blib -e my\ $sh\ =\ \<a\>.SetHash;\ for\ $sh.pairs\ {\ .value\ =\ 0;\ .value\ =\ 1\ }
==13508== 
==13508== Invalid read of size 4
==13508==    at 0x4149A82: MVM_iterkey_s (MVMIter.c:333)
==13508==    by 0x40DACC0: MVM_interp_run (interp.c:2708)
==13508==    by 0x41C7413: MVM_vm_run_file (moar.c:323)
==13508==    by 0x8048F39: main (main.c:246)
==13508==  Address 0x9cc52c0 is 24 bytes inside a block of size 36 free'd
==13508==    at 0x402B3D8: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==13508==    by 0x410C42B: MVM_free (alloc.h:29)
==13508==    by 0x410CC81: MVM_fixed_size_free (fixedsizealloc.c:259)
==13508==    by 0x413A966: delete_key (MVMHash.c:126)
==13508==    by 0x40D8D59: MVM_interp_run (interp.c:2394)
==13508==    by 0x41C7413: MVM_vm_run_file (moar.c:323)
==13508==    by 0x8048F39: main (main.c:246)

有关此问题的讨论, 请参见https://irclog.perlgeek.de/perl6-dev/2017-05-26#i_14641221

原文:

The following piece of code causes valgrind to complain about invalid reads:

$sh = <a>.SetHash;
for $sh.values { $_ = 0; $_ = 1 }

# valgrind run of the code above

dogbert@dogbert-VirtualBox ~/repos/rakudo $ ./perl6-valgrind-m  -e 'my $sh = <a>.SetHash; for $sh.pairs { .value = 0; .value = 1 }'
================================================================================================
This is Rakudo Perl 6 running in valgrind, a tool for debugging and profiling programs.
Running a program in valgrind usually takes *a lot* more time than running it directly,
so please be patient.
This Rakudo version is 2017.05.91.gf.2.fca.0.c.8.c built on MoarVM version   2017.05.24.gd.86.a.35.b.6,
running on ubuntu (14.04.3.LTS.Trusty.Tahr) / linux (3.19.0.32.generic)
------------------------------------------------------------------------------------------------
==13508== Memcheck, a memory error detector
==13508== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==13508== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
==13508== Command: /home/dogbert/repos/rakudo/install/bin/moar --execname=./perl6-ugga --libpath=/home/dogbert/repos/rakudo/install/share/nqp/lib --libpath=/home/dogbert/repos/rakudo/install/share/nqp/lib --libpath=. /home/dogbert/repos/rakudo/perl6.moarvm --nqp-lib=blib -e my\ $sh\ =\ \<a\>.SetHash;\ for\ $sh.pairs\ {\ .value\ =\ 0;\ .value\ =\ 1\ }
==13508== 
==13508== Invalid read of size 4
==13508==    at 0x4149A82: MVM_iterkey_s (MVMIter.c:333)
==13508==    by 0x40DACC0: MVM_interp_run (interp.c:2708)
==13508==    by 0x41C7413: MVM_vm_run_file (moar.c:323)
==13508==    by 0x8048F39: main (main.c:246)
==13508==  Address 0x9cc52c0 is 24 bytes inside a block of size 36 free'd
==13508==    at 0x402B3D8: free (in /usr/lib/valgrind/vgpreload_memcheck-x86-linux.so)
==13508==    by 0x410C42B: MVM_free (alloc.h:29)
==13508==    by 0x410CC81: MVM_fixed_size_free (fixedsizealloc.c:259)
==13508==    by 0x413A966: delete_key (MVMHash.c:126)
==13508==    by 0x40D8D59: MVM_interp_run (interp.c:2394)
==13508==    by 0x41C7413: MVM_vm_run_file (moar.c:323)
==13508==    by 0x8048F39: main (main.c:246)

See https://irclog.perlgeek.de/perl6-dev/2017-05-26#i_14641221 for a discussion about this

相关推荐
最新评论 (1)
lizmat 2017-10-9
1

这可能是一个高尔夫球的问题:

使用 nqp;
我的 $h: = nqp:: 散列 ("a", 42);
我的 $i: = nqp:: 迭代器 ($h);
我的 $n: = nqp:: iterkey_s (nqp:: 移位 ($i));
nqp::d eletekey ($h, $n);
nqp:: bindkey ($h, $n, 666);
dd $h

原文:

This is probably a golf of the problem:

use nqp;
my $h := nqp::hash("a",42);
my $i := nqp::iterator($h);
my $n := nqp::iterkey_s(nqp::shift($i));
nqp::deletekey($h,$n);
nqp::bindkey($h,$n,666);
dd $h

返回
发表文章
dogbert17
文章数
1
评论数
0
注册排名
60691