I have successfully executed the cmake and make command to build target in dsent of gem5
But it comes a segmentation fault as below when I execute import dsent
Python ver: 3.10
Segfault happened at: 0x557878f5cc15<PyLong_AsLongLong+21>: testb $Ox1,0xab(%rax)PC(Ox557878f5cc15)ok
source "$ox1" ok
destination "Oxab(%rax)"(Oxffffo603090703aa)not located in a known vMA region(needed writable region)!
and this is my only function using PyLong_AsLongLong()
static PyObject* dsent_computeLinkPower(PyObject *self, PyObject *arg) {
uint64_t frequency = PyLong_AsLongLong(arg);
// Read the arguments sent from the python script
if (frequency == -1) {
Py_RETURN_NONE;
}
// DSENT outputs
map<string, double> outputs;
params["Frequency"] = String(frequency);
// Run DSENT
DSENT::run(params, ms_model, outputs);
// Store outputs
PyObject *r = PyTuple_New(outputs.size());
int index = 0;
// Prepare the output. The assumption is that all the output
for (const auto &it : outputs) {
PyObject *s = PyTuple_New(2);
PyTuple_SetItem(s, 0, PyUnicode_FromString(it.first.c_str()));
PyTuple_SetItem(s, 1, PyFloat_FromDouble(it.second));
PyTuple_SetItem(r, index, s);
index++;
}
return r;
}
I've modified some py3.x deprecated c extension API to the newest version, such as PyModule_Create()
, PyUnicode_AsUTF8()