<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent changes to 204: Segfault when using callbacks</title><link href="https://sourceforge.net/p/raspberry-gpio-python/tickets/204/" rel="alternate"/><link href="https://sourceforge.net/p/raspberry-gpio-python/tickets/204/feed.atom" rel="self"/><id>https://sourceforge.net/p/raspberry-gpio-python/tickets/204/</id><updated>2022-04-18T18:05:03.020000Z</updated><subtitle>Recent changes to 204: Segfault when using callbacks</subtitle><entry><title>Segfault when using callbacks</title><link href="https://sourceforge.net/p/raspberry-gpio-python/tickets/204/" rel="alternate"/><published>2022-04-18T18:05:03.020000Z</published><updated>2022-04-18T18:05:03.020000Z</updated><author><name>Barney Stratford</name><uri>https://sourceforge.net/u/bjs31/</uri></author><id>https://sourceforge.net9e76f9d8c837a3a75e479c543c5ff25a0eb029a0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;The following causes a use-after-free bug:&lt;br/&gt;
RPi.GPIO.add_event_detect (channel, edge, callback = RPi.GPIO.remove_event_detect)&lt;/p&gt;
&lt;p&gt;Look at the function run_py_callbacks starting at line 586 of source/py_gpio.c In the example given above, calling the callback in line 597 causes the memory pointed to by cb to be freed. If it is overwritten before line 605 (cb = cb-&amp;gt;next), then cb goes into hyperspace and a segfault follows.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>