Memory Context problems...

Started by Katsaros Kwn/nosabout 21 years ago3 messages
#1Katsaros Kwn/nos
ntinos@aueb.gr

Hi everybody,
I have some problems with management of memory contexts (at least I
thing so). I'll try to describe my problem in a few lines:

I've written some code based on spi.c. I've created my_spi.c (and
my_spi.h) which provide some more features I wanted (did not alter spi
itself to keep code clear). Anyway, I've managed to get them into the
backend and call some of the functions from a user defined function. The
problem is that I experience some problems during the transition from
one memory context to another.

More precisely,when I call (my_)SPI_prepare the following message comes
exactly at the point where (my_)SPI_end_call(true) is called:

WARNING: problem in alloc set my_SPI Exec: detected write past chunk
end in block 0x830b7e8, chunk 0x830c058
WARNING: problem in alloc set my_SPI Exec: detected write past chunk
end in block 0x8307720, chunk 0x830b6cc

Moreover, when I true to call (my_)SPI_finish the server crashes.

Note, that the results expected from the my_SPI calls are returned
correctly.

Any ideas? I think it is something with the memory contexts but
obviously this is not enough to solve the problem.

Thank you in advance!
Ntinos Katsaros

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Katsaros Kwn/nos (#1)
Re: Memory Context problems...

"Katsaros Kwn/nos" <ntinos@aueb.gr> writes:

More precisely,when I call (my_)SPI_prepare the following message comes
exactly at the point where (my_)SPI_end_call(true) is called:

WARNING: problem in alloc set my_SPI Exec: detected write past chunk
end in block 0x830b7e8, chunk 0x830c058
WARNING: problem in alloc set my_SPI Exec: detected write past chunk
end in block 0x8307720, chunk 0x830b6cc

Any ideas? I think it is something with the memory contexts but
obviously this is not enough to solve the problem.

I'd bet on buffer-overrun problems. Check your allocation request sizes
against what's actually being used.

regards, tom lane

#3Katsaros Kwn/nos
ntinos@aueb.gr
In reply to: Tom Lane (#2)
Re: Memory Context problems...

On Sun, 2004-11-07 at 21:31, Tom Lane wrote:

"Katsaros Kwn/nos" <ntinos@aueb.gr> writes:

More precisely,when I call (my_)SPI_prepare the following message comes
exactly at the point where (my_)SPI_end_call(true) is called:

WARNING: problem in alloc set my_SPI Exec: detected write past chunk
end in block 0x830b7e8, chunk 0x830c058
WARNING: problem in alloc set my_SPI Exec: detected write past chunk
end in block 0x8307720, chunk 0x830b6cc

Any ideas? I think it is something with the memory contexts but
obviously this is not enough to solve the problem.

I'd bet on buffer-overrun problems. Check your allocation request sizes
against what's actually being used.

I tried to increase the allocated memory using ALLOCSET_DEFAULT_*SIZE
just to see what would happen, but nothing.What is returned is a Plan
node and some (3 in my example) Query nodes. All inside a List. Are
these too big to fit?

When my user defined procedure (that calls my_SPI functions) returns,
the following message also appears:

WARNING: problem in alloc set my_SPI Results: detected write past chunk
end in block 0x8313550, chunk 0x8315140

which is obviously about the same kind of problem. The thing is that I
noticed that this latter message appears as many times as I palloc
inside my_SPI_copy_results() function which is an extension of
_SPI_copy_plan().

I cannot understand what the problem is since I do similar things with
_SPI_copy_plan. I palloc() exactly at the same places with the original
func. Is it that I use Lists as a mean of returning multiple objects to
the user defined function or even that I call another function that
pallocs before calling my_SPI_copy_results() (this other function
produces the Query nodes)? Are there any other places in the source
other than (my_)spi.c, (my_)spi.h and xact.c (AtEOXact_(my_)SPI() call)
that I should make an entry regarding my code?

Thanks for your interest!
Ntinos