Page MenuHomeFreeBSD

libc: Do not refer to _DefaultRuneLocale in ctype inlines.
ClosedPublic

Authored by jilles on Apr 11 2017, 9:48 PM.
Tags
None
Referenced Files
F133367392: D10363.id27363.diff
Sat, Oct 25, 6:00 AM
Unknown Object (File)
Fri, Oct 10, 9:45 PM
Unknown Object (File)
Sat, Sep 27, 11:07 AM
Unknown Object (File)
Sep 14 2025, 7:15 AM
Unknown Object (File)
Aug 28 2025, 10:04 PM
Unknown Object (File)
Aug 4 2025, 3:42 AM
Unknown Object (File)
Aug 4 2025, 3:12 AM
Unknown Object (File)
Aug 2 2025, 3:35 AM

Details

Summary

Referring to _DefaultRuneLocale causes this >4KB structure to be copied to
all executables that use <ctype.h> inlines (except PIE executables).

This only affects the case where thread local storage is available.

Reading the lib/libc/locale code, it seems like _CurrentRuneLocale cannot be
NULL (since the non-TLS __getCurrentRuneLocale() and other places use struct
xlocale_ctype.runes without checking), so the check can be removed entirely.
If this reading is incorrect, it seems best to add a check to the assignment
of _CurrentRuneLocale in lib/libc/locale/setrunelocale.c.

Test Plan

installworld in a VM and kyua test of bin, usr.bin and lib/libc.

Diff Detail

Event Timeline

Found some other bugs while reading this code too!

This revision is now accepted and ready to land.Sep 22 2017, 9:30 AM

This probably means that we no longer need to expose _DefaultRuneLocale in the header.

This probably means that we no longer need to expose _DefaultRuneLocale in the header.

libc++ (contrib/libc++/src/locale.cpp) uses _DefaultRuneLocale, so it should remain available for now.

The __isctype inline in include/_ctype.h also refers to _DefaultRuneLocale, but it is not used.

This revision was automatically updated to reflect the committed changes.