Skip to content

Commit

Permalink
Revert #1322 to fix #1035
Browse files Browse the repository at this point in the history
  • Loading branch information
Triton Library committed Jul 25, 2024
1 parent 8d6d347 commit 4f27564
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .build_number
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1593
1594
7 changes: 7 additions & 0 deletions src/libtriton/bindings/python/objects/pyTritonContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,10 +503,12 @@ namespace triton {
if (PyMethod_Check(function)) {
cb_self = PyMethod_GET_SELF(function);
cb = PyMethod_GET_FUNCTION(function);
Py_INCREF(cb_self);
}
else {
cb = function;
}
Py_INCREF(cb);

try {
switch (static_cast<triton::callbacks::callback_e>(PyLong_AsUint32(mode))) {
Expand Down Expand Up @@ -2624,6 +2626,11 @@ namespace triton {
return PyErr_Format(PyExc_TypeError, "%s", e.what());
}

Py_DECREF(cb);
if (cb_self != nullptr) {
Py_DECREF(cb_self);
}

Py_INCREF(Py_None);
return Py_None;
}
Expand Down
14 changes: 14 additions & 0 deletions src/testers/unittests/test_github_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ def test_2(self):
x0 = self.ctx.getConcreteRegisterValue(self.ctx.registers.x0)
self.assertEqual(x0, 0x55667788)


class TestIssue1310(unittest.TestCase):
"""Testing #1310."""

Expand Down Expand Up @@ -700,3 +701,16 @@ def test_2(self):

self.assertEqual(ctx.getConcreteRegisterValue(ctx.registers.tpidr_el0), 0x1122334455667788)
self.assertEqual(ctx.getConcreteRegisterValue(ctx.registers.x20), 0x1122334455667788)


class TestIssue1035(unittest.TestCase):
def setup_callback(self, ctx):
def getMem(triton_ctx, memacc):
self.x = 1234
ctx.addCallback(CALLBACK.GET_CONCRETE_MEMORY_VALUE, getMem)

def test_1(self):
ctx = TritonContext(ARCH.X86_64)
self.setup_callback(ctx)
ctx.getConcreteMemoryAreaValue(0x1000, 0x1)
self.assertEqual(self.x, 1234)

0 comments on commit 4f27564

Please sign in to comment.