提交 e054ea66 编写于 作者: S Skylot

fix: adjust limits to skip processing of large methods (#1012)

上级 0deafb76
......@@ -290,6 +290,10 @@ public class MethodGen {
code.startLine("// Can't load method instructions.");
return;
}
if (insnArr.length > 100) {
code.startLine("// Method dump skipped, instructions count: " + insnArr.length);
return;
}
code.incIndent();
if (mth.getThisArg() != null) {
code.startLine(nameGen.useArg(mth.getThisArg())).add(" = this;");
......@@ -305,6 +309,7 @@ public class MethodGen {
}
public static void addFallbackInsns(CodeWriter code, MethodNode mth, InsnNode[] insnArr, FallbackOption option) {
int startIndent = code.getIndent();
InsnGen insnGen = new InsnGen(getFallbackMethodGen(mth), true);
boolean attachInsns = mth.root().getArgs().isJsonOutput();
InsnNode prevInsn = null;
......@@ -349,8 +354,9 @@ public class MethodGen {
if (catchAttr != null) {
code.add(" // " + catchAttr);
}
} catch (CodegenException e) {
} catch (Exception e) {
LOG.debug("Error generate fallback instruction: ", e.getCause());
code.setIndent(startIndent);
code.startLine("// error: " + insn);
}
prevInsn = insn;
......
package jadx.core.dex.visitors;
import jadx.core.dex.attributes.AType;
import jadx.core.dex.nodes.ClassNode;
import jadx.core.dex.nodes.MethodNode;
import jadx.core.utils.DebugChecks;
......@@ -19,6 +20,9 @@ public class DepthTraversal {
public static void visit(IDexTreeVisitor visitor, MethodNode mth) {
try {
if (mth.contains(AType.JADX_ERROR)) {
return;
}
visitor.visit(mth);
if (DebugChecks.checksEnabled) {
DebugChecks.runChecksAfterVisitor(mth, visitor);
......
......@@ -69,8 +69,7 @@ public class BlockProcessor extends AbstractVisitor {
updateExitBlocks(mth);
if (i++ > 100) {
mth.addWarn("CFG modification limit reached, blocks count: " + mth.getBasicBlocks().size());
break;
throw new JadxRuntimeException("CFG modification limit reached, blocks count: " + mth.getBasicBlocks().size());
}
}
checkForUnreachableBlocks(mth);
......
......@@ -34,6 +34,7 @@ import jadx.core.dex.nodes.MethodNode;
public class TypeSearch {
private static final Logger LOG = LoggerFactory.getLogger(TypeSearch.class);
private static final int VARS_PROCESS_LIMIT = 5_000;
private static final int CANDIDATES_COUNT_LIMIT = 10;
private static final int SEARCH_ITERATION_LIMIT = 1_000_000;
......@@ -50,6 +51,11 @@ public class TypeSearch {
}
public boolean run() {
if (mth.getSVars().size() > VARS_PROCESS_LIMIT) {
mth.addWarnComment("Multi-variable search skipped. Vars limit reached: " + mth.getSVars().size()
+ " (expected less than " + VARS_PROCESS_LIMIT + ")");
return false;
}
mth.getSVars().forEach(this::fillTypeCandidates);
mth.getSVars().forEach(this::collectConstraints);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册