Re: bad awk output on vkernel

看板DFBSD_kernel作者時間16年前 (2009/08/18 20:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串6/6 (看更多)
On Thu, Aug 13, 2009 at 11:48:18PM -0700, Matthew Dillon wrote: > Is this with the latest master ? I did fix some pipe bugs last week > which could very well cause this sort of behavior (where the data gets > corrupted through the pipe). I'm pretty sure I got all the bugs, there > shouldn't be any left. > > If it isn't that I'll have to try to reproduce it on a test bed and > then track the issue down. I'd say it's not a pipe issue, but specific to running awk on vkernel, because this perl version never produces bad output on vkernel: my $SUBSEP = "\034"; my $flag = 0; my @record; while (<>) { chomp; if (/^[ \t]*(;|$)/) { $flag = 0; next; } if (/^[^ \t]/) { if ($flag == 0) { push(@record, $_); $flag = 1; } else { my $l = @record - 1; $record[$l] .= $SUBSEP; $record[$l] .= $_; } } } foreach (sort @record) { print $_, "\n"; } My guess is that awk on vkernel has problem handling an array of long strings, especially its elements are assigned to in a non-sequential way; if I commented the line calling sort() function and it greatly reduced the probability of inconsistent output :) I also tried gawk from pkgsrc, but it seems to have similar issue. Probably I need to take a closer look at the source code.
文章代碼(AID): #1AYfz5yV (DFBSD_kernel)
文章代碼(AID): #1AYfz5yV (DFBSD_kernel)