Skip to content

Commit

Permalink
fix: resolve some multi-thread issues
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Jul 25, 2019
1 parent ab97084 commit 472aa52
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion jadx-core/src/main/java/jadx/core/codegen/InsnGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ private void makeConstructor(ConstructorInsn insn, CodeWriter code)
code.add("new ");
useClass(code, insn.getClassType());
ArgType argType = insn.getResult().getSVar().getCodeVar().getType();
if (argType.isGeneric()) {
if (argType != null && argType.isGeneric()) {
code.add('<');
if (insn.contains(AFlag.EXPLICIT_GENERICS)) {
boolean first = true;
Expand Down
5 changes: 3 additions & 2 deletions jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,12 @@ private void addMethodArguments(CodeWriter code, List<RegisterArg> args) {
code.add("final ");
}
ArgType argType;
if (var.getType() == ArgType.UNKNOWN) {
ArgType varType = var.getType();
if (varType == null || varType == ArgType.UNKNOWN) {
// occur on decompilation errors
argType = mthArg.getInitType();
} else {
argType = var.getType();
argType = varType;
}
if (!it.hasNext() && mth.getAccessFlags().isVarArgs()) {
// change last array argument to varargs
Expand Down
2 changes: 1 addition & 1 deletion jadx-core/src/main/java/jadx/core/dex/nodes/InsnNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ protected final <T extends InsnNode> T copyCommonParams(T copy) {
InsnNode wrapInsn = ((InsnWrapArg) arg).getWrapInsn();
copy.addArg(InsnArg.wrapArg(wrapInsn.copy()));
} else {
copy.addArg(arg);
copy.addArg(arg.duplicate());
}
}
}
Expand Down
9 changes: 0 additions & 9 deletions jadx-core/src/main/java/jadx/core/dex/nodes/RootNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import jadx.core.utils.ErrorsCounter;
import jadx.core.utils.StringUtils;
import jadx.core.utils.android.AndroidResourcesUtils;
import jadx.core.utils.exceptions.DecodeException;
import jadx.core.utils.exceptions.JadxRuntimeException;
import jadx.core.utils.files.DexFile;
import jadx.core.utils.files.InputFile;
Expand Down Expand Up @@ -232,14 +231,6 @@ public ArgType getMethodGenericReturnType(MethodInfo callMth) {
MethodNode methodNode = deepResolveMethod(callMth);
if (methodNode != null) {
ArgType returnType = methodNode.getReturnType();
if (returnType == null) {
try {
methodNode.load();
returnType = methodNode.getReturnType();
} catch (DecodeException e) {
LOG.error("Method load error", e);
}
}
if (returnType != null && (returnType.isGeneric() || returnType.isGenericType())) {
return returnType;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package jadx.core.dex.visitors;

import java.util.ArrayList;
import java.util.List;

import com.android.dx.rop.code.AccessFlags;
Expand Down Expand Up @@ -93,7 +94,14 @@ private static void addInlineAttr(MethodNode mth, InsnNode insn) {
if (Consts.DEBUG) {
mth.addAttr(AType.COMMENTS, "Removed for inline");
} else {
mth.addAttr(new MethodInlineAttr(insn));
InsnNode copy = insn.copy();
// unbind SSA variables from copy instruction
List<RegisterArg> regArgs = new ArrayList<>();
copy.getRegisterArgs(regArgs);
for (RegisterArg regArg : regArgs) {
copy.replaceArg(regArg, regArg.duplicate(regArg.getRegNum(), null));
}
mth.addAttr(new MethodInlineAttr(copy));
mth.add(AFlag.DONT_GENERATE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import jadx.core.utils.ErrorsCounter;
import jadx.core.utils.InsnRemover;
import jadx.core.utils.RegionUtils;
import jadx.core.utils.exceptions.JadxOverflowException;
import jadx.core.utils.exceptions.JadxRuntimeException;

import static jadx.core.dex.visitors.regions.IfMakerHelper.confirmMerge;
Expand Down Expand Up @@ -86,7 +87,7 @@ public Region makeRegion(BlockNode startBlock, RegionStack stack) {
next = traverse(r, next, stack);
regionsCount++;
if (regionsCount > regionsLimit) {
throw new JadxRuntimeException("Regions count limit reached");
throw new JadxOverflowException("Regions count limit reached");
}
}
return r;
Expand Down

0 comments on commit 472aa52

Please sign in to comment.