Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dataset bug fix #157

Merged
merged 3 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ private static Set<PointsToSetVariable> getDataflowSources(
processInstructionInterprocedurally(
propertyRead, objectRef, localPointerKeyNode, src, sources, pointerAnalysis);
} else if (def instanceof EachElementGetInstruction
|| def instanceof PythonPropertyRead) {
|| def instanceof PythonPropertyRead
|| def instanceof PythonInvokeInstruction) {
processInstruction(
def,
du,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,10 @@

import com.ibm.wala.cast.ipa.callgraph.AstSSAPropagationCallGraphBuilder;
import com.ibm.wala.cast.ipa.callgraph.GlobalObjectKey;
import com.ibm.wala.cast.ir.ssa.AstPropertyRead;
import com.ibm.wala.cast.ir.ssa.EachElementGetInstruction;
import com.ibm.wala.cast.python.ipa.summaries.BuiltinFunctions.BuiltinFunction;
import com.ibm.wala.cast.python.ir.PythonLanguage;
import com.ibm.wala.cast.python.ssa.PythonInstructionVisitor;
import com.ibm.wala.cast.python.ssa.PythonInvokeInstruction;
import com.ibm.wala.cast.python.ssa.PythonPropertyRead;
import com.ibm.wala.cast.python.types.PythonTypes;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IField;
Expand All @@ -40,7 +37,6 @@
import com.ibm.wala.ssa.SSAArrayStoreInstruction;
import com.ibm.wala.ssa.SSABinaryOpInstruction;
import com.ibm.wala.ssa.SSAGetInstruction;
import com.ibm.wala.ssa.SSAInstruction;
import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.FieldReference;
import com.ibm.wala.types.TypeReference;
Expand Down Expand Up @@ -179,42 +175,6 @@ public String toString() {
super.visitGet(instruction);
}

@Override
public void visitPropertyRead(AstPropertyRead instruction) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, could I get a bit more info on why we are removing this handling? Just want to understand better

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. This is my fault; the handling is wrong. What was happening below is that we were adding a constraint that basically said for x = obj.f then x := f, which completely ignores object ref. This was happening in a "for each element" traversal. I guess it solved some bug, but I found bugs, as you can imagine, it created. Adding the code above in the PythonTensorAnalysisEngine solved the same bug(s) but (I believe) in a correct way.

This is happening another instance of a weird test setup where some behavior works in this project but not in a client project. I believe the problem is related to #42. Our client uses Jython 3 but the Ariadne ML tests use just plain Jython. Since a core focus of Ariadne is to calculate the tensor shapes, we didn't want to switch to Jython 3 until #42 is fixed. Our client, however, is using Jython 3 for ML code because we are not yet using tensor shapes (just type inference for now). So, what happens is that it works here but not in our client, which winds up causing us to create multiple fixes for bugs :(.

I don't think #42 is a super involved fix, but it requires some investigation. We started ponder-lab#42 with some progress. I hope to get back to it soon.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, I think that Jython should be completely replaced by Jython 3 here at some point, meaning that we should end support for Python 2.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the details!

super.visitPropertyRead(instruction);

if (instruction instanceof PythonPropertyRead) {
PythonPropertyRead ppr = (PythonPropertyRead) instruction;
SSAInstruction memberRefDef = du.getDef(ppr.getMemberRef());

if (memberRefDef != null && memberRefDef instanceof EachElementGetInstruction) {
// most likely a for each "property."
final PointerKey memberRefKey = this.getPointerKeyForLocal(ppr.getMemberRef());

// for each def of the property read.
for (int i = 0; i < ppr.getNumberOfDefs(); i++) {
PointerKey defKey = this.getPointerKeyForLocal(ppr.getDef(i));

// add an assignment constraint straight away as the traversal variable won't have a
// non-empty points-to set but still may be used for a dataflow analysis.
if (this.system.newConstraint(defKey, assignOperator, memberRefKey))
logger.fine(
() ->
"Added new system constraint for global read from: "
+ defKey
+ " to: "
+ memberRefKey
+ " for instruction: "
+ instruction
+ ".");
else
logger.fine(
() -> "No constraint added for global read in instruction: " + instruction + ".");
}
}
}
}

@Override
public void visitPythonInvoke(PythonInvokeInstruction inst) {
visitInvokeInternal(inst, new DefaultInvariantComputer());
Expand Down
Loading