[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#374354: libgdbm3: gdbm_open continually reopens file in a loop until it runs out of file descriptors and fails.



control: close -1

> When I try yo invoke gdbm_open, the call appears to internally open and
> reopen the specified file until we run out of file descriptors, at which
> point gdbm_open fails with gdbm_errno 3(File open failure) and errno 24
> (Too many open files).
>
> This will officially be my first bug report, so be kind if I make any
> faux pauxes! Thanks. :)

Your first bug report is very good. Thank you.

But it is not real bug. Issue is that you call your function `write',
which is collision with normal write(2) function.

In this situation I would expect linker error, but what actually happens
is that your function shadows write(2) one. Problem is that `gdbm_open'
internally uses write(2), so here we have endless rescursion.

If you have little available descriptors, result will be as you described.
If you have many available described, result will be stack overflow and
segfault. It happens on my system.

Try renaming your `write' function into `my_own_write' and check again.
Closing bug for now. Feel free to reopen it, if `my_own_write' would still
misbehave.

> #include<gdbm.h>
> #include<stdio.h>
> #include<errno.h>
>
> void write()
> {
>   GDBM_FILE dbf;
>
>   if( (dbf = gdbm_open("test.gdb", 0, GDBM_NEWDB, 0640, NULL)) == NULL)
>   {
>     printf("dat file open error (%d,%d): %s/%s\n", gdbm_errno, errno,
> gdbm_strerror(gdbm_errno), strerror(errno));
>     exit(1);
>   }
>
>   gdbm_close(dbf);
> }
>
> int main()
> {
>   write();
> }

BTW, main function must return something, otherwise exit code is
undefined.

--
X-Web-Site: https://sinsekvu.github.io | Note that I process my email in batch,
Accept-Languages: eo,ru,en             | at most once every 24 hours. If matter
Accept: text/plain, text/x-diff        | is urgent, you have my phone number.

Attachment: pgpELBRfT7YUR.pgp
Description: PGP signature


Reply to: