Created attachment 131847 [details] gdb debugging log
dlmopen will segfault in the rtld when passed flags LM_ID_NEWLM and RTLD_GLOBAL|RTLD_NOW. Failure is at dl-open.c line 102/103: 99 if (GL(dl_ns)[new->l_ns]._ns_global_scope_alloc == 0) 100 { 101 /* This is the first dynamic object given global scope. */ 102 GL(dl_ns)[new->l_ns]._ns_global_scope_alloc 103 = GL(dl_ns)[new->l_ns]._ns_main_searchlist->r_nlist + to_add + 8; 104 new_global = (struct link_map **) 105 malloc (GL(dl_ns)[new->l_ns]._ns_global_scope_alloc 106 * sizeof (struct link_map *)); because _rtld_local._dl_ns[new->l_ns]._ns_main_searchlist is NULL.
Created attachment 131848 [details] test program
It makes no sense to use RTLD_GLOBAL when dlmopen loads the object in anything but the first namespace. I added a test to catch that upstream. It'll be in the next rawhide release.