Re: Print warning when I execute my own extension function

From: Dong Wook Lee <sh95119(at)gmail(dot)com>
To: Julien Rouhaud <rjuju123(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Print warning when I execute my own extension function
Date: 2022-02-20 14:51:24
Message-ID: CAAcByaK=biSv4pKDPcLDmPTNGjENr15qAP5+V6wu_2x752nmNA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I found a source code line that prints warning in the source code
(src/backend/utils/mmgr/aset.c, line 1496)
/*
│ 1492 * Check for overwrite of
padding space in an allocated chunk.
│ 1493 */
│ 1494 if (chunk->aset == (void *)
set && dsize < chsize &&
│ 1495 !sentinel_ok(chunk,
ALLOC_CHUNKHDRSZ + dsize))
│B+>1496 elog(WARNING, "problem
in alloc set %s: detected write past chunk end in block %p, chunk %p",
│ 1497 name, block, chunk);

In my extension c code.
I assigned value at the allocated memory address
and I found this assigned statement occurs warning
should I don't use it like this?
```
char *buffer = palloc(7 * sizeof(char));
unsigned int offset = sizeof(buffer);
> buffer[--offset] = '\0'; /* here */
```

2022년 2월 20일 (일) 오후 7:29, Julien Rouhaud <rjuju123(at)gmail(dot)com>님이 작성:
>
> Hi,
>
> On Sun, Feb 20, 2022 at 07:23:56PM +0900, Dong Wook Lee wrote:
> > Hi hackers,
> > I've read in this blog (
> > http://big-elephants.com/2015-10/writing-postgres-extensions-part-i/)
> > and I wrote an extension about base36_encode with c code
> > but when I executed a query like this below I got a warning below.
> >
> > ```
> > postgres=# SELECT base36_encode(123);
> > WARNING: problem in alloc set ExprContext: detected write past chunk end
> > in block 0x55fb75334d40, chunk 0x55fb75334d68
> > WARNING: problem in alloc set ExprContext: detected write past chunk end
> > in block 0x55fb75334d40, chunk 0x55fb75334d68
> > base36_encode
> > ---------------
> > 3f
> > (1 row)
> > ```
> >
> > I don't know what this warning means and how I can fix it.
>
> It means that you have some problem in your memory allocation. You can refer
> to src/backend/utils/mmgr/aset.c for more details on those safety checks.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2022-02-20 15:03:17 Re: Removing more vacuumlazy.c special cases, relfrozenxid optimizations
Previous Message Robert Haas 2022-02-20 14:45:05 Re: pgsql: Add support for building with ZSTD.