Hi,

I am using below code to read the value of array of strings to the perl script.

Everything works fine, if the perl array size is less than 127. If the array size crosses 127. Abort is seen in sv_setpv function (Heap Corruption in Windows).

SWIG Perl Code to read the character array from the c++ library to perl:

{ int i = 0; while (result[i]) { if(i+1>items){ EXTEND(sp,1); } ST(argvi+i) = sv_newmortal(); sv_setpv((SV *)ST(argvi+i),result[i]);  Abort is hap +pening this point delete [] result[i]; i++; } argvi+=i; delete [] result; }

Is there any limitation in stack size of something else which is causing the issue ?.

Is there is a way overcome this issue ?.

Crash Dump:

FAULTING_THREAD: 0000000000000c5c DEFAULT_BUCKET_ID: HEAP_CORRUPTION PRIMARY_PROBLEM_CLASS: HEAP_CORRUPTION BUGCHECK_STR: APPLICATION_FAULT_HEAP_CORRUPTION_NULL_CLASS_PTR_DEREFE +RENCE_INVALID_POINTER_READ_WRONG_SYMBOLS_FILL_PATTERN_ffffffff LAST_CONTROL_TRANSFER: from 00007ffb262d21b2 to 00007ffb262d23c3 STACK_TEXT: 00000000`001bee80 00007ffb`262d21b2 : 00000000`02000002 00007ffb`00000 +000 00000000`000000a8 00000000`00000000 : ntdll!RtlAllocateHeap+0x2f3 00000000`001bef30 00007ffb`25f01d36 : 00000000`00000001 00000000`00000 +002 00000000`000000a8 00000000`00000000 : ntdll!RtlAllocateHeap+0xe2 00000000`001bf040 00000000`5825996d : 00000000`00000090 00000000`007a5 +df8 00000000`00000001 00000000`585125f0 : msvcrt!malloc+0x56 00000000`001bf070 00000000`58262a9a : 00000000`00000002 00000000`5848d +ef1 00000000`00000000 00000000`000000c5 : perl516!VMem::Malloc+0x1d [ +e:\codavs05\hpsw-opcsi\external\perl\5.16.0\win5.2_64\perl-5.16.0\win +32\vmem.h @ 166] 00000000`001bf0a0 00000000`5829bee5 : 00000000`022c2630 00000000`00000 +090 00000000`007a5df8 00000000`01dd44f0 : perl516!Perl_safesysmalloc+ +0x4a [e:\codavs05\hpsw-opcsi\external\perl\5.16.0\win5.2_64\perl-5.16 +.0\util.c @ 102] 00000000`001bf0d0 00000000`5828e521 : 00000000`022c2630 00000000`007a5 +df8 00000000`00000003 00000000`00000000 : perl516!Perl_sv_grow+0x135 +[e:\codavs05\hpsw-opcsi\external\perl\5.16.0\win5.2_64\perl-5.16.0\sv +.c @ 1521] 00000000`001bf100 00007ffb`1d87cf03 : 00000000`007a5df8 00000000`00000 +003 00000000`022c5dc8 00000000`00000000 : perl516!Perl_sv_setpv+0xb1 +[e:\codavs05\hpsw-opcsi\external\perl\5.16.0\win5.2_64\perl-5.16.0\sv +.c @ 4550]

suggest me, is there is a way to read the array for more than 127 array size.

Thanks and Regards,

Thiyagu

2018-08-02 Athanasius added code and paragraph tags


In reply to sv_setpv aborts when the SV (perl output array)have more than 127 size by Thiyagu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.