error()/error_at_line() and threads

Florian Weimer fweimer@redhat.com
Thu Jun 11 16:44:40 GMT 2026


> the man page further has the rather over-optimistic:
>
>        The internal error_one_per_line variable is accessed (without any
>        form of synchronization, but since it's an int used once, it
>        should be safe enough), and if error_one_per_line is set nonzero,
>        the internal static variables (not exposed to users) used to hold
>        the last printed filename and line number are accessed and
>        modified without synchronization; the update is not atomic and it
>        occurs before disabling cancelation, so it can be interrupted only
>        after one of the two variables is modified.  After that,
>        error_at_line() is very much like error().
>
> but neither say anything about error_message_count. a quick test
> program shows that, as you'd expect, some increments get lost in the
> presence of many threads.

With glibc?  That's surprising because we lock stderr before updating
error_message_count.

Thanks,
Florian



More information about the Libc-alpha mailing list