Project

General

Profile

Actions

Bug #10549

open

libtopo uses umem_*() functions - consumers should link umem

Added by Andy Fiddaman over 4 years ago.

Status:
In Progress
Priority:
Normal
Assignee:
Category:
lib - userland libraries
Start date:
2019-03-13
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:
External Bug:

Description

This came up during recent work to upstream some old commits from Delphix.

18 months ago, Pavel Zakharov posted to the developers' list, starting a thread about problems that can occur if both libc and libumem's memory allocators are both used in the same process: https://illumos.topicbox.com/groups/developer/Tf6b5c9db433d96de-M6746103a48549dcc57649b48

In illumos today, libtopo is linked with libumem and uses explicit calls to umem_*() functions. However, the following utilities that are linked with libtopo are not linked with libumem which results in allocators from both libraries being used.

Pavel Zakharov

The two memory allocators were designed to be exclusive, as they independently call the brk/sbrk syscalls to manage the heap space, and thus are likely to result in collisions of virtual address assignments, a.k.a memory corruption.

The affected utilities are:
  • /usr/sbin/fmadm
  • /usr/sbin/fmdump
  • /usr/lib/fm/fmd/fmtopo
  • /usr/sbin/prtdiag
  • /usr/bin/diskinfo

For example, the following shows that malloc() is being bound to libc, and umem_alloc() to libumem.

% /lib/ld.so.1 -e LD_DEBUG=all /usr/lib/fm/fmd/fmtopo 2>&1 | egrep "symbol '(malloc|umem_)" 
11097: binding file=/lib/libc.so.1 to file=/lib/libc.so.1: symbol 'malloc'
11097: 1: binding file=/lib/libxml2.so.2 to file=/usr/lib/fm/fmd/fmtopo: symbol 'malloc'
11097: 1: binding file=/lib/libxml2.so.2 to file=/usr/lib/fm/fmd/fmtopo: symbol 'malloc'
11097: 1: binding file=/lib/libxml2.so.2 to file=/usr/lib/fm/fmd/fmtopo: symbol 'malloc'
11097: 1: binding file=/usr/lib/fm/libtopo.so.1 to file=/lib/libumem.so.1: symbol 'umem_alloc'
11097: 1: binding file=/lib/libumem.so.1 to file=/lib/libumem.so.1: symbol 'umem_reap'
11097: 1: binding file=/lib/libumem.so.1 to file=/lib/libumem.so.1: symbol 'umem_cache_create'
11097: 1: binding file=/usr/lib/fm/libtopo.so.1 to file=/lib/libumem.so.1: symbol 'umem_free'
11097: 1: binding file=/lib/libuutil.so.1 to file=/lib/libc.so.1: symbol 'malloc'
11097: 1: binding file=/lib/libdevinfo.so.1 to file=/lib/libc.so.1: symbol 'malloc'

Until the underlying issue is resolved, the libtopo consumers should explicitly link libumem.

No data to display

Actions

Also available in: Atom PDF