Many answers to other questions help resolve an error of the form "failed to map segment from shared object," but they usually have very specific answers that I find difficult to apply to other problems. On the other hand, I can't find anything about this error in general.

Can anyone give a basic description of this error and (ideally) some common causes?

It would be nice to know, for example, which entity raises the error (the kernel, the process, the program?) and common reasons why (e.g. almost every library is marked readable, so why can't I map from it?).

I am currently running Ubuntu, although I suspect this is applies to many distributions.

  • Why the downvote?
    – Zach Boyd
    Commented Jan 23, 2019 at 19:16
  • It's probably because you don't give an example; a possible cause could be a mismatch between a program and the dynamic libraries it's using, maybe caused by some clever fix like creating a link from libfoo.so.4 to libfoo.so.3 to get the foo program requiring libfoo.so.4 to run.
    – user313992
    Commented Jan 24, 2019 at 2:24
  • 1
    Thanks. Not including a specific example was kind of the point of the question, but I know there are lots of people at SE to love to hate on more general questions.
    – Zach Boyd
    Commented Jan 24, 2019 at 14:41

1 Answer 1


That message is generated by the dynamic linker (ld.so(8)) or the dynamic loading facilities (dlopen(3)).

To answer your questions directly: a) it's not from the kernel b) it's from a process in user mode c) it's usually not generated by a program's main code, but by the dynamic linker which is loading it or a dynamic library it's using (libdl.so) and d) the fact that a segment could be read from a file doesn't mean it could be mmaped with the right protection (eg. executable) or that it could be be mmaped at the address required (if using MAP_FIXED with a bogus address, instead of that of a known mapping which should be replaced).

If you want more detail, you'll see that it's defined in the glibc source code in elf/dl-load.h as DL_MAP_SEGMENTS_ERROR_MAP_SEGMENT, and could be returned by the _dl_map_segments() static function, which is itself called via _dl_map_object() => _dl_map_object_from_fd(), and _dl_map_object() is called either directly from the dynamic linker, or via its .dl_open callback ultimately called by dlopen(3).

  • 1
    Thank you very much for the explanation. I will spend some time looking through the links. I have never been through glibc source code or anything that low level, so it will be an adventure. It sounds like the eventual answer is that something must be stopping the mmap operation that is required for dynamic linking. Would it be possible to add a bit about what entities control whether mmap-ing is possible? (Assuming it is not already answered in the links.) This seems like the purview of the file system/operating system/SELinux, etc.? Presumably what address is mapped to is in the links.
    – Zach Boyd
    Commented Jan 24, 2019 at 14:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .