Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: sv_setpvn called with negative strlen #11048

Closed
p5pRT opened this issue Jan 18, 2011 · 8 comments
Closed

panic: sv_setpvn called with negative strlen #11048

p5pRT opened this issue Jan 18, 2011 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 18, 2011

Migrated from rt.perl.org#82414 (status was 'rejected')

Searchable as RT82414$

@p5pRT
Copy link
Author

p5pRT commented Jan 18, 2011

From xliosha@gmail.com

Created by xliosha@gmail.com

This is a bug report for perl from xliosha@​gmail.com,
generated with the help of perlbug 1.39 running under perl 5.12.2.

-----------------------------------------------------------------

Hi!

I try to output unicode stream via '​:encoding(cp1250)' layer.
Some symbols doesn't map to this encoding, so i get warnings​:

"\x{0456}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637, <$_[...]> line 2460557.
"\x{043d}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637, <$_[...]> line 2460557.
"\x{043d}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637, <$_[...]> line 2460557.
"\x{0438}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637, <$_[...]> line 2460557.
"\x{0446}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637, <$_[...]> line 2460557.
and so on.

And _sometimes_ after few such warnings perl crashes with message​:

panic​: sv_setpvn called with negative strlen at C​:\buf\osm\osm2mp.pl line 2375, <$_[...]> line 4001961.

Maybe there are problems with octet counting in such cases?

Perl Info

Flags:
    category=core
    severity=medium

This perlbug was built using Perl 5.12.0 - Sun Apr 11 11:18:23 2010
It is being executed now by  Perl 5.12.2 - Sun Apr 11 11:18:23 2010.

Site configuration information for perl 5.12.2:

Configured by SYSTEM at Sun Apr 11 11:18:23 2010.

Summary of my perl5 (revision 5 version 12 subversion 0) configuration:
   
  Platform:
    osname=MSWin32, osvers=5.00, archname=MSWin32-x86-multi-thread
    uname=''
    config_args='undef'
    hint=recommended, useposix=true, d_sigaction=undef
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cl', ccflags ='-nologo -GF -W3 -MD -Zi -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
    optimize='-MD -Zi -DNDEBUG -O1',
    cppflags='-DWIN32'
    ccversion='..', gccversion='', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'
    libpth=\lib
    libs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
    perllibs=  oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
    libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl512.lib
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug -opt:ref,icf  -libpath:"C:\Perl\lib\CORE"  -machine:x86'

Locally applied patches:
    ACTIVEPERL_LOCAL_PATCHES_ENTRY


@INC for perl 5.12.2:
    C:/Perl/site/lib
    C:/Perl/lib
    .


Environment for perl 5.12.2:
    HOME (unset)
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files\PC Connectivity Solution\;c:\Program Files\NVIDIA Corporation\PhysX\Common;C:\tools\imagick;C:\Perl\site\bin;C:\Perl\bin;C:\WINXP\system32;C:\WINXP;C:\WINXP\System32\Wbem;c:\tools;c:\tools\my;C:\tools\apache-ant-1.7.1\bin;C:\Program Files\Mercurial;C:\WINXP\system32\WindowsPowerShell\v1.0;C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;C:\sperl\c\bin;C:\sperl\perl\site\bin;C:\sperl\perl\bin;C:\Program Files\Subversion\bin;C:\Program Files\Common Files\Microsoft Shared\Windows Live
    PERL_BADLANG (unset)
    SHELL (unset)


@p5pRT
Copy link
Author

p5pRT commented Feb 5, 2011

From @smpeters

Hi!

I try to output unicode stream via '​:encoding(cp1250)' layer.
Some symbols doesn't map to this encoding, so i get warnings​:

"\x{0456}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637,
<$_[...]> line 2460557.
"\x{043d}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637,
<$_[...]> line 2460557.
"\x{043d}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637,
<$_[...]> line 2460557.
"\x{0438}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637,
<$_[...]> line 2460557.
"\x{0446}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637,
<$_[...]> line 2460557.
and so on.

And _sometimes_ after few such warnings perl crashes with message​:

panic​: sv_setpvn called with negative strlen at C​:\buf\osm\osm2mp.pl
line 2375, <$_[...]> line 4001961.

Maybe there are problems with octet counting in such cases?

Thanks for your report. Unfortunately, without some sample code and
data it is difficult to replicate and investigate this problem. Can you
provide a simplified test case that replicates this problem?

Steve

@p5pRT
Copy link
Author

p5pRT commented Feb 5, 2011

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Feb 6, 2011

From xliosha@gmail.com

Hello.

This code causes such crash in a few seconds​:

use 5.010;
binmode STDOUT, '​:encoding(cp1250)';
while (1) {
  my $string = join q{}, map { chr(rand 0x500) } (0..rand 1000);
  say $string;
}

Hi!

I try to output unicode stream via '​:encoding(cp1250)' layer.
Some symbols doesn't map to this encoding, so i get warnings​:

"\x{0456}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637,
<$_[...]> line 2460557.
"\x{043d}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637,
<$_[...]> line 2460557.
"\x{043d}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637,
<$_[...]> line 2460557.
"\x{0438}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637,
<$_[...]> line 2460557.
"\x{0446}" does not map to cp1250 at C​:\buf\osm\osm2mp.pl line 2637,
<$_[...]> line 2460557.
and so on.

And _sometimes_ after few such warnings perl crashes with message​:

panic​: sv_setpvn called with negative strlen at C​:\buf\osm\osm2mp.pl
line 2375, <$_[...]> line 4001961.

Maybe there are problems with octet counting in such cases?

Thanks for your report. Unfortunately, without some sample code and
data it is difficult to replicate and investigate this problem. Can you
provide a simplified test case that replicates this problem?

Steve

--
С уважением,
liosha mailto​:xliosha@​gmail.com

@p5pRT
Copy link
Author

p5pRT commented Feb 7, 2011

From @ikegami

On Sat, Feb 5, 2011 at 6​:19 AM, liosha <xliosha@​gmail.com> wrote​:

This code causes such crash in a few seconds​:

use 5.010;
binmode STDOUT, '​:encoding(cp1250)';
while (1) {
my $string = join q{}, map { chr(rand 0x500) } (0..rand 1000);
say $string;
}

Reproduced with blead @​g76cc22e

#0 Perl_sv_setpvn (sv=0x8320068, ptr=0x83388e1 "", len=4294967295) at
sv.c​:4454
#1 0xb7708793 in encode_method (enc=0xb722389c, dir=0xb7225c60,
src=0x8320068, check=<value optimized out>, offset=0x0, term=0x0,
retcode=0x0, fallback_cb=0x831c628) at Encode.xs​:266
#2 0xb77092cf in XS_Encode__XS_encode (cv=0x83a17b8) at Encode.xs​:657
#3 0x08138203 in Perl_pp_entersub () at pp_hot.c​:2931
#4 0x080fe127 in Perl_runops_debug () at dump.c​:2267
#5 0x08083288 in Perl_call_sv (sv=0x8320b38, flags=130) at perl.c​:2614
#6 0xb723792b in PerlIOEncode_flush (f=0x832bdd8) at encoding.xs​:424
#7 0x082492e3 in PerlIOBuf_write (f=0x832bdd8, vbuf=0x83bc2a0, count=546)
at perlio.c​:4157
#8 0xb72391f3 in PerlIOEncode_write (f=0x832bdd8, vbuf=0x83bc2a0,
count=1570) at encoding.xs​:593
#9 0x08211839 in Perl_do_print (sv=0x8331560, fp=0x832bdd8) at doio.c​:1257
#10 0x08145979 in Perl_pp_print () at pp_hot.c​:773
#11 0x080fe127 in Perl_runops_debug () at dump.c​:2267
#12 0x08084b7b in perl_run (my_perl=0x831d008) at perl.c​:2332
#13 0x08062f25 in main (argc=3, argv=0xbfffc9b4, env=0xbfffc9c4) at
perlmain.c​:120

Deterministic test case​:

binmode STDOUT, '​:encoding(cp1250)';
print map chr,
1146, 627, 46, 891, 583, 542, 507, 1169, 1162, 663, 577, 518, 223, 526,
1016, 885, 1135, 1077, 16, 774, 802, 623, 1164, 235,
1136, 1027, 1, 502, 1222, 132, 1127, 738, 747, 115, 315, 23, 643, 455, 815,
1026, 140, 725, 405, 12, 208, 511, 680, 906,
816, 392, 103, 71, 1039, 926, 1163, 953, 38, 1175, 335, 1032, 950, 865, 992,
59, 575, 1263, 227, 216, 1265, 1036, 1189, 365,
667, 403, 1157, 548, 150, 415, 7, 1142, 621, 630, 668, 691, 435, 176, 1152,
396, 1015, 236, 1202, 296, 997, 1115, 1206, 910,
997, 621, 8, 173, 455, 481, 7, 342, 448, 744, 417, 46, 19, 280, 608, 466,
169, 1271, 195, 574, 1246, 1213, 777, 473, 169,
806, 382, 232, 304, 1088, 473, 612, 1011, 1248, 986, 284, 1149, 427, 353,
1110, 287, 957, 229, 378, 793, 48, 114, 1173, 767,
673, 769, 869, 368, 348, 663, 665, 1007, 1180, 871, 561, 1267, 501, 255,
734, 1194, 117, 317, 69, 525, 378, 391, 753, 128,
672, 772, 675, 250, 389, 153, 1245, 1141, 419, 1214, 581, 109, 371, 1000,
1241, 1106, 552, 163, 262, 511, 141, 240, 501,
705, 612, 1256, 432, 4, 28, 959, 381, 196, 567, 134, 722, 4, 40, 360, 603,
359, 518, 979, 189, 316, 1054, 1035, 161, 850,
343, 43, 487, 210, 275, 643, 707, 514, 826, 1213, 1123, 773, 1130, 322, 679,
203, 721, 837, 997, 140, 563, 803, 255, 890,
163, 48, 786, 637, 1048, 110, 942, 309, 1015, 398, 603, 903, 387, 449, 814,
700, 544, 477, 436, 794, 631, 1014, 774, 1104,
1164, 703, 1278, 1267, 1216, 678, 88, 932, 861, 629, 669, 772, 314, 880,
128, 263, 130, 739, 799, 790, 871, 1200, 151, 131,
677, 237, 363, 377, 1276, 1275, 69, 1067, 165, 710, 1011, 560, 1239, 316,
1061, 970, 1043, 1035, 241, 634, 1157, 5, 1091,
332, 1252, 1106, 381, 837, 942, 328, 1268, 452, 892, 796, 1183, 282, 666,
1151, 1123, 402, 1109, 1023, 804, 344, 1214, 722,
928, 870, 721, 308, 536, 1048, 820, 217, 1028, 1252, 1054, 438, 66, 999,
1056, 275, 742, 931, 1213, 608, 224, 697, 358, 855,
132, 705, 477, 1222, 570, 424, 324, 28, 759, 963, 193, 150, 1098, 513, 607,
901, 449, 411, 75, 725, 1247, 982, 274, 752, 63,
179, 545, 617, 544, 436, 1086, 1001, 224, 149, 1054, 225, 66, 402, 364, 288,
1156, 76, 1105, 950, 421, 203, 172, 1091, 1230,
498, 632, 954, 296, 1067, 690, 391, 126, 251, 445, 466, 740, 843, 116, 216,
827, 924, 1113, 406, 1211, 1094, 522, 940, 304,
100, 286, 249, 888, 1175, 652, 184, 267, 1168, 231, 668, 323, 1087, 404,
736, 450, 969, 693, 4, 1082, 959, 321, 1017, 892,
16, 1162, 1166, 1271, 578, 209, 48, 913, 1116, 25, 661, 901, 854, 643, 827,
1142, 1261, 289, 998, 45, 743, 1245, 421, 1204,
472, 117, 345, 1013, 1239, 895, 278, 1235, 1097, 730, 539, 628, 863, 327,
137, 1083, 490, 871, 1021, 468, 938, 1022, 553,
903, 677, 109, 1239, 115, 627, 1188, 656, 986, 79, 730, 1270, 168, 1089,
1086, 759, 247, 794, 1210, 340, 138, 226, 1069, 46,
454, 447, 643, 840, 382, 493, 58, 968, 1263, 6, 1058, 567, 647, 747, 252,
888
;

- Eric

@p5pRT
Copy link
Author

p5pRT commented Feb 7, 2011

From @ikegami

Hi,

This appears to be a bug in Encode, and Encode is maintained separately
from Perl. As such, I'm closing this ticket. I've already opened a
ticket in Encode's queue for you​:

https://rt.cpan.org/Ticket/Display.html?id=65541

Thanks,
Eric Brine

@p5pRT
Copy link
Author

p5pRT commented Feb 7, 2011

From [Unknown Contact. See original ticket]

Hi,

This appears to be a bug in Encode, and Encode is maintained separately
from Perl. As such, I'm closing this ticket. I've already opened a
ticket in Encode's queue for you​:

https://rt.cpan.org/Ticket/Display.html?id=65541

Thanks,
Eric Brine

@p5pRT
Copy link
Author

p5pRT commented Feb 7, 2011

@ikegami - Status changed from 'open' to 'rejected'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant