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

It's a bit hard to read your code as presented. Please use <code>...</code> around your code to make it render as a code block.

I'm not sure that your code is actually sound, as you seem to have objects stored in the result array, but then copy pointers to Perl space (via sv_setpv) and also call delete [] on them, if I understand the C++ code correctly. But that leaves the memory in a very bad state, because delete [] will also have called the destructor on the object referenced by result[i], and you still have a pointer to that memory location stored in ST(argvi+i). This will result in memory corruption and many things can happen there.

{ 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 happening +this point delete [] result[i]; i++; } argvi+=i; delete [] result; }

My suggestion would be to remove all calls to delete until you get things working and then add the delete [] result; back, maybe. But even then you need to make sure that the contents of result themselves are not removed, because they are now referenced from Perl space.