Skip Menu |

This queue is for tickets about the Unicode-LineBreak CPAN distribution.

Report information
The Basics
Id: 106714
Status: resolved
Priority: 0/
Queue: Unicode-LineBreak

People
Owner: Nobody in particular
Requestors: AARONRP [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2013.004_26
Fixed in: 2015.12



Subject: Unicode-GCString does not stringify numeric arguments (and gives malloc errors)
Unicode::GCString does not handle numeric arguments, at least when using the columns method. Ideally it would stringify them and use the results of the stringification. When I tried it in my larger code, it just gave 0 instead of the number of columns. In my minimal test case, it gives a malloc error.
Subject: gctest.out
Download gctest.out
application/octet-stream 348b

Message body not shown because it is not plain text.

Subject: gctest.pl
#!/usr/bin/env perl use strict; use warnings; use Unicode::GCString; my $str_gcs = Unicode::GCString::->new("5"); print "String: " , $str_gcs->columns , "\n"; my $num_gcs = Unicode::GCString::->new(5); print "Number: " , $str_gcs->columns, "\n";
Subject: perl-v.out
Download perl-v.out
application/octet-stream 3.3k

Message body not shown because it is not plain text.

It seems that this bug already fixed: * https://github.com/hatukanezumi/Unicode-LineBreak/pull/1
On Mon Oct 19 21:50:54 2015, joenio wrote: Show quoted text
> It seems that this bug already fixed: > > * https://github.com/hatukanezumi/Unicode-LineBreak/pull/1
Adding tests does not fix the problem SVupgradetounistr () calls SvCUR () on an SvIV which returns junk (a very large number) This is perl 5, version 14, subversion 2 (v5.14.2) built for IA64.ARCHREV_0-LP64-ld .cpan/build/Unicode-LineBreak-2015.11-46_Fzg $ make test : t/10gcstring.t ........... 1/37 SVupgradetounistr: Not enough space at /home/merijn/.cpan/build/Unicode-LineBreak-2015.11-46_Fzg/blib/lib/Unicode/GCString.pm line 46. # Looks like you planned 37 tests but ran 35. # Looks like your test exited with 12 just after 35. t/10gcstring.t ........... Dubious, test returned 12 (wstat 3072, 0xc00) Failed 2/37 subtests .cpan/build/Unicode-LineBreak-2015.11-46_Fzg $ perl -Mblib -MUnicode::GCString -wE'$_=Unicode::GCString->new (5)' SVupgradetounistr: Not enough space at /home/merijn/.cpan/build/Unicode-LineBreak-2015.11-46_Fzg/blib/lib/Unicode/GCString.pm line 46. At line 121, str is SV = IV(0x60000000000724d8) at 0x60000000000724e8 REFCNT = 1 FLAGS = (IOK,READONLY,pIOK) IV = 5 NO PV! The code should add if (!SvOK(str)) return buf; if (!SvPOK(str)) sv_upgrade(str, SVt_PVIV); But that makes the test fail. It is up to the maintainer to decide what steps to take from here The full code as I tested: --8<--- static unistr_t *SVupgradetounistr(unistr_t *buf, SV *str) { char *s; size_t len, i; if (buf == NULL) { if ((buf = malloc(sizeof(unistr_t))) == NULL) croak("SVupgradetounistr: %s", strerror(errno)); } else if (buf->str) free(buf->str); buf->str = NULL; buf->len = 0; if (!SvOK(str)) return buf; if (!SvPOK(str)) sv_upgrade(str, SVt_PVIV); len = SvCUR(str); if (len == 0) return buf; if ((buf->str = malloc(sizeof(unichar_t) * len)) == NULL) croak("SVupgradetounistr: %s", strerror(errno)); s = SvPV(str, len); for (i = 0; i < len; i++) buf->str[i] = (unichar_t)(unsigned char)s[i]; buf->len = len; return buf; } -->8---
I see that the fix is https://github.com/hatukanezumi/Unicode-LineBreak/commit/eeea487e665e1de66d4dee8c91954e2b5d3ad903 I ended up with if (!SvOK(str)) return buf; if (!SvPOK(str)) { SvUPGRADE(str, SVt_PVIV); s = SvPV_nolen(str); } len = SvCUR(str); before alh pointed me to the fix
Hi, On 2015-11月-03 火 08:22:04, HMBRAND wrote: Show quoted text
> I see that the fix is https://github.com/hatukanezumi/Unicode- > LineBreak/commit/eeea487e665e1de66d4dee8c91954e2b5d3ad903 > > I ended up with > > if (!SvOK(str)) > return buf; > > if (!SvPOK(str)) { > SvUPGRADE(str, SVt_PVIV); > s = SvPV_nolen(str); > } > len = SvCUR(str); > > before alh pointed me to the fix
I at first tried exactly same change as you did! But after all, I comitted a change using SvPV() --- It seems implicitly upgrading non-PV. I might be wrong. Would you please check 2015.011_03 on CPAN? Regards, -- Soji
Subject: Unicode-GCString does not stringify numeric arguments (and gives malloc errors)
On 2015-11-03 05:39:13, NEZUMI wrote: Show quoted text
> Would you please check 2015.011_03 on CPAN?
cpanm --dev Unicode::GCString does not install the latest release, because 2015.011_03 is numerically less than the last indexed release, 2015.11.