public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jengelh at inai dot de" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug locale/31143] New: Let iconv_open return EMFILE if RLIMIT_NOFILE is hit
Date: Tue, 12 Dec 2023 02:00:33 +0000	[thread overview]
Message-ID: <bug-31143-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=31143

            Bug ID: 31143
           Summary: Let iconv_open return EMFILE if RLIMIT_NOFILE is hit
           Product: glibc
           Version: 2.38
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: locale
          Assignee: unassigned at sourceware dot org
          Reporter: jengelh at inai dot de
  Target Milestone: ---

Consider a program that opens a lot of file descriptors, by chance so happens
to stay just barely under the limit, and at some point uses iconv_open.
Pathalogical testcase:

#include <iconv.h>
#include <sys/resource.h>
#include <stdio.h>
int main()
{
        struct rlimit rl = {3,3};
        if (setrlimit(RLIMIT_NOFILE, &rl) != 0) 
                perror("setrlimit");

        iconv_t cd = iconv_open("UTF-8", "windows-1254//IGNORE");
        if (cd == (iconv_t)-1)
                perror("iconv_open");
}

== Observed behavior

On a typical linux-glibc system, this will report:

       iconv_open: Invalid argument

== Expected

       iconv_open: Too many files open

glibc iconv is implemented with shared plugins (/usr/lib/gconv), thus the
implementation is susceptible to fd limits. Though EINVAL is not incorrect per
se (no module loaded - no charset available), it could help the admin to see an
EMFILE errno.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

             reply	other threads:[~2023-12-12  2:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-12  2:00 jengelh at inai dot de [this message]
2023-12-12  9:26 ` [Bug locale/31143] " fweimer at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-31143-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).