Skip to contentSkip to conversation

eal: do not try to load library with a local pathname

PATCH In review David Marchand 3 participants 3 messages Apr 15, 2014 – Apr 17, 2014 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 eal: do not try to load library with a local pathname

From: Pascal Mazon <[email protected]>

When loading a library "libfoo.so" (depending on "libbar.so", located in an entirely different folder), with a LD_LIBRARY_PATH=/path/to/libfoo.so", it returns an error:

EAL: ./libfoo.so: cannot open shared object file: No such file or directory

If the first dlopen() fails (here, because it can't find all dependencies), the code requires for a second dlopen() that looks for "./libfoo.so". It turns on pathname matching, which does not use LD_LIBRARY_PATH. As a result, it fails because it cannot find "./libfoo.so".

The error message matches the error of the second dlopen(), not the first's.

Do not try to look for a different library ("./"-prefixed) than the one provided in argument. Let the dynamic library management handle it, just provide an appropriate LD_LIBRARY_PATH.

---
 lib/librte_eal/linuxapp/eal/eal.c |    6 ------
 1 file changed, 6 deletions(-)
lib/librte_eal/linuxapp/eal/eal.c +0 -6
index 3ded563..d2753ec 100644
@@ -1049,12 +1049,6 @@ rte_eal_init(int argc, char **argv)
 	TAILQ_FOREACH(solib, &solib_list, next) {
 		RTE_LOG(INFO, EAL, "open shared lib %s\n", solib->name);
 		solib->lib_handle = dlopen(solib->name, RTLD_NOW);
-		if ((solib->lib_handle == NULL) && (solib->name[0] != '/')) {
-			/* relative path: try again with "./" prefix */
-			char sopath[PATH_MAX];
-			snprintf(sopath, sizeof(sopath), "./%s", solib->name);
-			solib->lib_handle = dlopen(sopath, RTLD_NOW);
-		}
 		if (solib->lib_handle == NULL)
 			RTE_LOG(WARNING, EAL, "%s\n", dlerror());
 	}
Signature · 1 line
1.7.10.4

A message that is not in the archive (sent off-list or not yet received): 1397569822-3294-1-git-send-email-david.marchand-pdR9zngts4EAvxtiuMwx3w@public.gmane.org

Acked-by
#2 lore raw
Quoted 13 lines · David Marchand

From: Pascal Mazon <[email protected]>

When loading a library "libfoo.so" (depending on "libbar.so", located in an entirely different folder), with a LD_LIBRARY_PATH=/path/to/libfoo.so", it returns an error:

EAL: ./libfoo.so: cannot open shared object file: No such file or directory

If the first dlopen() fails (here, because it can't find all dependencies), the code requires for a second dlopen() that looks for "./libfoo.so". It turns on pathname matching, which does not use LD_LIBRARY_PATH. As a result, it fails because it cannot find "./libfoo.so".

Quoted 7 lines

The error message matches the error of the second dlopen(), not the first's.

Do not try to look for a different library ("./"-prefixed) than the one provided in argument. Let the dynamic library management handle it, just provide an appropriate LD_LIBRARY_PATH.

Quoted 25 lines
---
 lib/librte_eal/linuxapp/eal/eal.c |    6 ------
 1 file changed, 6 deletions(-)
lib/librte_eal/linuxapp/eal/eal.c +0 -6
index 3ded563..d2753ec 100644
@@ -1049,12 +1049,6 @@ rte_eal_init(int argc, char **argv)
 	TAILQ_FOREACH(solib, &solib_list, next) {
 		RTE_LOG(INFO, EAL, "open shared lib %s\n", solib->name);
 		solib->lib_handle = dlopen(solib->name, RTLD_NOW);
-		if ((solib->lib_handle == NULL) && (solib->name[0] != '/')) {
-			/* relative path: try again with "./" prefix */
-			char sopath[PATH_MAX];
-			snprintf(sopath, sizeof(sopath), "./%s", solib->name);
-			solib->lib_handle = dlopen(sopath, RTLD_NOW);
-		}
 		if (solib->lib_handle == NULL)
 			RTE_LOG(WARNING, EAL, "%s\n", dlerror());
 	}
Signature · 1 line
1.7.10.4

A message that is not in the archive (sent off-list or not yet received): 20140415135704.GB3557-B26myB8xz7F8NnZeBjwnZQMhkBWG/[email protected]

#4 lore raw
Quoted 17 lines
Quoted 17 lines

When loading a library "libfoo.so" (depending on "libbar.so", located in an
entirely different folder), with a LD_LIBRARY_PATH=/path/to/libfoo.so", it

returns an error:
EAL: ./libfoo.so: cannot open shared object file: No such file or directory

If the first dlopen() fails (here, because it can't find all dependencies),
the code requires for a second dlopen() that looks for "./libfoo.so". It turns on pathname matching, which does not use LD_LIBRARY_PATH. As a result, it fails because it cannot find "./libfoo.so".

The error message matches the error of the second dlopen(), not the first's.

Quoted 7 lines
Quoted 5 lines

Do not try to look for a different library ("./"-prefixed) than the one provided in argument. Let the dynamic library management handle it, just provide an appropriate LD_LIBRARY_PATH.

Applied for version 1.6.0r2.

Thanks, it's a good usability improvement (simpler is better :)

Signature · 1 line
Thomas