<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello,<br>
<br>
I am trying to learn how to use the Python API of libqmi.<br>
I extended the simple-tester-python.py to press a key and query
some information.<br>
When trying to get the revision, I get the correct revision, but
afterwards I get the error message “free(): double free detected
in tcache 2”.<br>
I tried the same with getting the model, and same behaviour: Model
can be printed and is correct, but then same error message.<br>
<br>
When I comment out outputA.get_revision() as well as
outputB.get_model() (and not print the content, of course),<br>
the error message disappears.<br>
I saw in documentation (
<a class="moz-txt-link-freetext" href="https://lazka.github.io/pgi-docs/Qmi-1.0/classes/ClientDms.html#Qmi.ClientDms.get_revision_finish">https://lazka.github.io/pgi-docs/Qmi-1.0/classes/ClientDms.html#Qmi.ClientDms.get_revision_finish</a>
)<br>
that I shall: “The returned value should be freed with
Qmi.MessageDmsGetModelOutput.unref().”<br>
But this does not seem to make a difference.<br>
<br>
Can someone give me a hint, how I can debug and fix this? <br>
Where can I find the source code (python and/or C), which is
executed, when a Python function like get_revision() or
get_model() is called,<br>
till something is executed with/in libqmi? Or do I then directly
need to debug inside libqmi?<br>
<br>
PS: I have attached the complete python source code of my current
testing. Extension renamed from *.py to *.txt to avoid that mail
servers perhaps filter the file. Extracts below in the email. <br>
Keypress like ‘r’ are detected to execute the get revision action.<br>
And ‘m’ to get the radio module model. All just for testing, far
from cleaned up code!</p>
<p>I prepared the Linux environment with these commands (on a
Raspberry Pi 4 with latest Raspian OS from May 2023)</p>
<p>(only one time needed)<br>
</p>
<p><span><span
class="ui-provider a b c d e f g h i j k l m n o p q r s t u v w x y z ab ac ae af ag ah ai aj ak"
dir="ltr">
<p>sudo apt install python3-gi</p>
<p>sudo apt install libqmi-glib-dev</p>
<p>I execute it like the following:<br>
</p>
<p>sudo python3 connection-setup-bugreport.py /dev/cdc-wdm0</p>
<p>I assume does not matter, but I use a Quectel module
connected via USB.<br>
</p>
</span></span>Many thanks!<br>
<br>
Best regards,<br>
Martin<br>
<br>
</p>
<p>Output of my program (once pressing key "r", then restarting
program and pressing key "m"):<br>
</p>
<p>$ sudo python3 connection-setup.py /dev/cdc-wdm0<br>
new_ready<br>
wwan0<br>
open_ready<br>
allocate_client_DMS_ready<br>
allocate_client_DMS_ready: successful<br>
CID 45<br>
allocate_client_WDS_ready<br>
allocate_client_WDS_ready: successful<br>
<Qmi.ClientWds object at 0x7f93b22a00 (QmiClientWds at
0x3b904790)><br>
CID 46<br>
Call function r<br>
get_revision_ready<br>
Hallo A<br>
2<br>
Hallo B<br>
revision: RM520NGLAAR01A07M4G<br>
free(): double free detected in tcache 2<br>
Aborted<br>
$ sudo python3 connection-setup.py /dev/cdc-wdm0<br>
new_ready<br>
wwan0<br>
open_ready<br>
allocate_client_DMS_ready<br>
allocate_client_DMS_ready: successful<br>
CID 46<br>
allocate_client_WDS_ready<br>
allocate_client_WDS_ready: successful<br>
<Qmi.ClientWds object at 0x7f94076e00 (QmiClientWds at
0x4dd9790)><br>
CID 47<br>
Call function m<br>
get_model_ready<br>
Hallo A<br>
2<br>
Hallo B<br>
model: RM520N-GL<br>
free(): double free detected in tcache 2<br>
Aborted<br>
$<br>
<br>
<br>
def get_revision_ready(qmiclient,result,qmidev):<br>
print("get_revision_ready")<br>
<br>
try:<br>
outputA = qmiclient.get_revision_finish(result)<br>
errorOccured = outputA.get_result()<br>
<br>
available, revision = outputA.get_revision()<br>
<br>
# outputA.unref()<br>
<br>
print("Hallo A")<br>
<br>
print(sys.getrefcount(outputA))<br>
<br>
print("Hallo B")<br>
<br>
if available == True:<br>
print("revision: %s" % revision)<br>
else:<br>
print("revision: -> error getting
capabilities")<br>
<br>
except GLib.GError as error:<br>
sys.stderr.write("Couldn't query revision: %s\n" %
error.message)<br>
<br>
# output.unref()<br>
<br>
# release_client(qmidev, qmiclient)<br>
<br>
<br>
def get_model_ready(qmiclient,result,qmidev):<br>
print("get_model_ready")<br>
<br>
try:<br>
outputB = qmiclient.get_model_finish(result)<br>
errorOccured = outputB.get_result()<br>
<br>
available, model = outputB.get_model()<br>
<br>
# outputB.unref()<br>
<br>
print("Hallo A")<br>
<br>
print(sys.getrefcount(outputB))<br>
<br>
print("Hallo B")<br>
<br>
if available == True:<br>
print("model: %s" % model)<br>
else:<br>
print("model: -> error getting
capabilities")<br>
<br>
except GLib.GError as error:<br>
sys.stderr.write("Couldn't query model: %s\n" %
error.message)<br>
<br>
# output.unref()<br>
<br>
# release_client(qmidev, qmiclient)<br>
<br>
<br>
<br>
</p>
</body>
</html>