Commit 8a99de1
[libc][libdl] Fix dlopen() failing to find already-loaded modules
Fix name mismatch between dlmodule_find() and _dlmodule_set_name() that
caused dlopen() to always reload modules instead of reusing them:
1. In dlopen(): Extract module name from full path before calling
dlmodule_find(), matching the stripped name stored by _dlmodule_set_name().
This allows dlopen() to properly find and reuse already-loaded modules.
2. In _dlmodule_set_name(): Fix bug where extension detection searched
the entire path instead of just the filename portion. For paths like
"/mnt/v1.2/app.so", it would incorrectly find "." in "v1.2" directory
name instead of the ".so" extension.
Fixes: Module reloading on every dlopen() call, memory leaks from
duplicate module instances, and dlclose() cleanup issues.
Co-authored-by: BernardXiong <1241087+BernardXiong@users.noreply.github.com>1 parent ec3b2a2 commit 8a99de1
2 files changed
Lines changed: 64 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | | - | |
52 | | - | |
| 52 | + | |
| 53 | + | |
53 | 54 | | |
54 | | - | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
55 | 62 | | |
56 | 63 | | |
57 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
58 | 70 | | |
59 | 71 | | |
60 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
52 | 93 | | |
53 | 94 | | |
54 | 95 | | |
55 | 96 | | |
56 | | - | |
57 | | - | |
| 97 | + | |
| 98 | + | |
58 | 99 | | |
59 | | - | |
| 100 | + | |
60 | 101 | | |
61 | 102 | | |
62 | 103 | | |
| |||
67 | 108 | | |
68 | 109 | | |
69 | 110 | | |
70 | | - | |
| 111 | + | |
71 | 112 | | |
72 | 113 | | |
73 | 114 | | |
74 | 115 | | |
75 | | - | |
| 116 | + | |
76 | 117 | | |
77 | 118 | | |
0 commit comments