Skip to content

Commit 3c73566

Browse files
adicatanafacebook-github-bot
authored andcommitted
Explicit dep resolution for DirectorySoSources when BackupSoSource is enabled
Reviewed By: michalgr Differential Revision: D60834153 fbshipit-source-id: 6e66db5da2c73e2d1241aedbde6dc056e5641fb8
1 parent 9496e4c commit 3c73566

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

java/com/facebook/soloader/DirectorySoSource.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class DirectorySoSource extends SoSource {
3131
public static final int ON_LD_LIBRARY_PATH = 2;
3232

3333
protected final File soDirectory;
34-
protected final int flags;
34+
protected int flags;
3535
protected final List<String> denyList;
3636

3737
/**
@@ -47,6 +47,10 @@ public DirectorySoSource(File soDirectory, int flags) {
4747
this(soDirectory, flags, new String[0]);
4848
}
4949

50+
public void setExplicitDependencyResolution() {
51+
flags |= RESOLVE_DEPENDENCIES;
52+
}
53+
5054
/**
5155
* This method is similar to {@link #DirectorySoSource(File, int)}, with the following
5256
* differences:

java/com/facebook/soloader/recovery/ReunpackBackupSoSources.java

+20-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.facebook.soloader.recovery;
1818

1919
import com.facebook.soloader.BackupSoSource;
20+
import com.facebook.soloader.DirectorySoSource;
2021
import com.facebook.soloader.LogUtil;
2122
import com.facebook.soloader.SoLoader;
2223
import com.facebook.soloader.SoLoaderDSONotFoundError;
@@ -100,6 +101,7 @@ private boolean recoverDSONotFoundError(SoSource[] soSources, String soName, int
100101
}
101102

102103
private boolean lazyPrepareBackupSoSource(SoSource[] soSources, String soName) {
104+
boolean recovered = false;
103105
for (SoSource soSource : soSources) {
104106
if (!(soSource instanceof BackupSoSource)) {
105107
// NonApk SoSources get reunpacked in ReunpackNonBackupSoSource recovery strategy
@@ -111,7 +113,8 @@ private boolean lazyPrepareBackupSoSource(SoSource[] soSources, String soName) {
111113
SoLoader.TAG,
112114
"Preparing BackupSoSource for the first time " + backupSoSource.getName());
113115
backupSoSource.prepare(0);
114-
return true;
116+
recovered = true;
117+
break;
115118
} catch (Exception e) {
116119
// Catch a general error and log it, rather than failing during recovery and crashing the
117120
// app
@@ -128,6 +131,22 @@ private boolean lazyPrepareBackupSoSource(SoSource[] soSources, String soName) {
128131
}
129132
}
130133

134+
if (recovered) {
135+
for (SoSource soSource : soSources) {
136+
if (!(soSource instanceof DirectorySoSource)) {
137+
continue;
138+
}
139+
if (soSource instanceof BackupSoSource) {
140+
continue;
141+
}
142+
DirectorySoSource directorySoSource = (DirectorySoSource) soSource;
143+
// We need to explicitly resolve dependencies, as dlopen() cannot do
144+
// so for dependencies at non-standard locations.
145+
directorySoSource.setExplicitDependencyResolution();
146+
}
147+
return true;
148+
}
149+
131150
return false;
132151
}
133152

0 commit comments

Comments
 (0)