Eric Kort
2008-01-28 22:06:55 UTC
Unfortunately, when I attempt to recreate the error I am about to describe in a tidy little function, I can't. But within the larger context of my image processing routine, I am encountering the following strangeness:
I am trying to update an element of an AV using av_store, and all is well if I do this:
int newval;
...
for(y = 1; y < iGridHeight - 1; y++) {
for(x = 1; x < iGridWidth - 1; x++) {
newval = 12;
av_store(avGrid, y * iGridWidth + x, newSViv(newval));
}
}
But if I try to increment newval, it dies after 10 iterations (and always after 10 iterations):
int newval=12;
...
for(y = 1; y < iGridHeight - 1; y++) {
for(x = 1; x < iGridWidth - 1; x++) {
newval++;
av_store(avGrid, y * iGridWidth + x, newSViv(newval));
}
}
With this kind of error:
*** glibc detected *** perl: munmap_chunk(): invalid pointer: 0x00007fff7f692410 ***
======= Backtrace: =========
/lib64/libc.so.6[0x2b472ba4739e]
...
Sadly, when I break this out into a little demo function, it runs fine:
void worksFine (SV* sv_ar)
{
AV* av_ar;
int i, newv=2;
av_ar = (AV*)SvRV(sv_ar);
for(i=0; i<1000000; i++) {
newv++;
av_store(av_ar, 1, newSViv(newv));
}
return;
}
Nevertheless, I wonder if you have any insights into what is going wrong (or does the situation dependency of my problem suggest I am doing something evil with my memory management elsewhere?)
Thanks,
Eric
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient(s) please contact the sender by reply email and destroy all copies of the original message. Thank you.
I am trying to update an element of an AV using av_store, and all is well if I do this:
int newval;
...
for(y = 1; y < iGridHeight - 1; y++) {
for(x = 1; x < iGridWidth - 1; x++) {
newval = 12;
av_store(avGrid, y * iGridWidth + x, newSViv(newval));
}
}
But if I try to increment newval, it dies after 10 iterations (and always after 10 iterations):
int newval=12;
...
for(y = 1; y < iGridHeight - 1; y++) {
for(x = 1; x < iGridWidth - 1; x++) {
newval++;
av_store(avGrid, y * iGridWidth + x, newSViv(newval));
}
}
With this kind of error:
*** glibc detected *** perl: munmap_chunk(): invalid pointer: 0x00007fff7f692410 ***
======= Backtrace: =========
/lib64/libc.so.6[0x2b472ba4739e]
...
Sadly, when I break this out into a little demo function, it runs fine:
void worksFine (SV* sv_ar)
{
AV* av_ar;
int i, newv=2;
av_ar = (AV*)SvRV(sv_ar);
for(i=0; i<1000000; i++) {
newv++;
av_store(av_ar, 1, newSViv(newv));
}
return;
}
Nevertheless, I wonder if you have any insights into what is going wrong (or does the situation dependency of my problem suggest I am doing something evil with my memory management elsewhere?)
Thanks,
Eric
This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient(s) please contact the sender by reply email and destroy all copies of the original message. Thank you.