Commit 58bba93
authored
Preload OpenSSL with RTLD_DEEPBIND on Linux to avoid clashing with Node's built-in copy (#691)
When the Foundry Local Core .so is loaded into Node on Linux, the first
HTTPS call from inside core (e.g. fetching the Azure catalog) crashes
the process. The crash is in EVP_KEYMGMT_is_a deep inside
libcrypto.so.3.
Node statically links its own copy of OpenSSL and re-exports those
symbols globally (the node binary is linked with --export-dynamic). When
core is loaded later, the .NET cryptography PAL pulls in the system
libcrypto.so.3 for SslStream / X509 verification. The system libcrypto
gets loaded with the dynamic linker's default flags, which means its own
internal function-to-function calls go through the global symbol scope.
And Node's same-named exports win the lookup. Node's OpenSSL and the
distro's libcrypto.so.3 don't agree on the layout of internal structs
like EVP_KEYMGMT, so the first time anything chases one of those
pointers we segfault.
Fix:
Before we load the core .so, dlopen libcrypto.so.3 (and libssl.so.3)
ourselves with RTLD_DEEPBIND. That tells the loader to resolve
libcrypto's undefined references against libcrypto's own scope first, so
its internal calls stay inside libcrypto. Anything that asks for
libcrypto.so.3 after that gets handed back our already-loaded, properly
isolated handle.
Falls back to libcrypto.so.1.1 / libssl.so.1.1 for older distros.
Best-effort: if neither is present, we just skip and let the load
continue.
Linux + glibc only; macOS already isolates dylibs via two-level
namespaces, and Windows isn't affected.1 parent 7e9043f commit 58bba93
2 files changed
Lines changed: 97 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
761 | 761 | | |
762 | 762 | | |
763 | 763 | | |
764 | | - | |
765 | | - | |
766 | | - | |
767 | | - | |
768 | | - | |
769 | | - | |
770 | | - | |
771 | | - | |
772 | | - | |
773 | | - | |
774 | | - | |
775 | | - | |
776 | | - | |
777 | | - | |
778 | | - | |
779 | | - | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
792 | 789 | | |
793 | 790 | | |
794 | 791 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
4 | 11 | | |
5 | 12 | | |
6 | 13 | | |
| |||
151 | 158 | | |
152 | 159 | | |
153 | 160 | | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
154 | 222 | | |
155 | 223 | | |
156 | 224 | | |
| |||
224 | 292 | | |
225 | 293 | | |
226 | 294 | | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
227 | 299 | | |
228 | 300 | | |
229 | 301 | | |
| |||
0 commit comments