Calling Setlocale(3C) Multiple Time Leaks Memory (Doc ID 2000322.1)

Last updated on AUGUST 03, 2016

Applies to:

Solaris Operating System - Version 11 11/11 to 11.2 [Release 11.0]
Information in this document applies to any platform.

Symptoms

Calling setlocale(3C) multiple times with different locales may leak memory.

Example output from ::findleaks in mdb:

> ::findleaks -dv
[...]
CACHE     LEAKED   BUFCTL CALLER
08071010      13 08092f20 libc_hwcap2.so.1`strdup+0x29
------------------------------------------------------------------------
   Total      13 buffers, 312 bytes
 
umem_alloc_24 leak: 13 buffers, 24 bytes each, 312 bytes total
            ADDR          BUFADDR        TIMESTAMP           THREAD
                            CACHE          LASTLOG         CONTENTS
         8092f20          808cf80   d2212a75ca56e0                1
                          8071010                0                0
                 libumem.so.1`umem_cache_alloc_debug+0x157
                 libumem.so.1`umem_cache_alloc+0x19d
                 libumem.so.1`umem_alloc+0xd0
                 libumem.so.1`malloc+0x2d
                 libc_hwcap2.so.1`strdup+0x29
                 libc_hwcap2.so.1`check_builtin_and_dup+0x3c
                 libc_hwcap2.so.1`locale_per_category+0xa1
                 libc_hwcap2.so.1`setlocale+0x53
                 main+0x1e
                 _start+0x7d

 

Changes

The problem occurs on Solaris 11 without the fix for unpublished bug 20077461.
The problem does not occur on Solaris 10.

The problem only occurs when the locale is different for different calls to setlocale(3C), and the category is different to LC_ALL.
The problem does not occur when setlocale(3C) is called repeatedly with the same locale.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms