Thanks for reporting.

Please test 8641: drivers/cmsis_dap: fix segfault in quirk mode setting | 
https://review.openocd.org/c/openocd/+/8641


---

**[tickets:#420] Segfault from cmsis-dap adapter quirk**

**Status:** new
**Milestone:** 0.11.0
**Created:** Wed Jan 24, 2024 04:08 PM UTC by Mark Featherston
**Last Updated:** Wed Jan 24, 2024 04:08 PM UTC
**Owner:** nobody


I'm testing against the latest code in git 
"151b743714382120dbe0dee0e0eeb75826ef5b3a"

I found when using this config file:
~~~
adapter driver cmsis-dap
cmsis-dap vid_pid 0x35b0 0x0001
cmsis-dap quirk on
transport select jtag
adapter speed 25000000
~~~

It segfaults here:
~~~
Program received signal SIGSEGV, Segmentation fault.
0x0000000000416233 in cmsis_dap_handle_quirk_command (cmd=0x7fffffffd810) at 
src/jtag/drivers/cmsis_dap.c:2232
2232                    COMMAND_PARSE_ENABLE(CMD_ARGV[0], 
cmsis_dap_handle->quirk_mode);
Missing separate debuginfos, use: dnf debuginfo-install 
capstone-4.0.2-15.fc39.x86_64 glibc-2.38-14.fc39.x86_64 
hidapi-0.14.0-2.fc39.x86_64 libcap-2.48-9.fc39.x86_64 
libftdi-1.5-10.fc39.x86_64 libgcc-13.2.1-6.fc39.x86_64 
libgpiod-2.0.2-1.fc39.x86_64 libjaylink-0.3.0-3.fc39.x86_64 
libusb1-1.0.26-3.fc39.x86_64 systemd-libs-254.7-1.fc39.x86_64
(gdb) bt
#0  0x0000000000416233 in cmsis_dap_handle_quirk_command (cmd=0x7fffffffd810) 
at src/jtag/drivers/cmsis_dap.c:2232
#1  0x0000000000489785 in exec_command (argv=0x80aef0, argc=2, c=0x80b650, 
context=0x7d82a0, interp=0x7d8300)
    at src/helper/command.c:520
#2  jim_command_dispatch (interp=0x7d8300, argc=2, argv=0x80aef0) at 
src/helper/command.c:931
#3  0x00000000005d32cf in JimInvokeCommand ()
#4  0x0000000700000006 in ?? ()
#5  0x000000000080af90 in ?? ()
#6  0x00000003007d8300 in ?? ()
#7  0x00007fffffffdb20 in ?? ()
#8  0x000000000064bec2 in ?? ()
#9  0x0000000000000005 in ?? ()
#10 0x0000000000000000 in ?? ()
~~~~

In gdb I found "cmsis_dap_handle" is null when this function is called:
~~~
COMMAND_HANDLER(cmsis_dap_handle_quirk_command)
{
        if (CMD_ARGC > 1)
                return ERROR_COMMAND_SYNTAX_ERROR;

        if (CMD_ARGC == 1)
                COMMAND_PARSE_ENABLE(CMD_ARGV[0], cmsis_dap_handle->quirk_mode);

        command_print(CMD, "CMSIS-DAP quirk workarounds %s",
                                  cmsis_dap_handle->quirk_mode ? "enabled" : 
"disabled");
        return ERROR_OK;
}
~~~

I'm not familiar with the command line parsing to know the proper fix for this, 
but hard coding it after the cmsis_dap_handle is set works.


---

Sent from sourceforge.net because openocd-devel@lists.sourceforge.net is 
subscribed to https://sourceforge.net/p/openocd/tickets/

To unsubscribe from further messages, a project admin can change settings at 
https://sourceforge.net/p/openocd/admin/tickets/options.  Or, if this is a 
mailing list, you can unsubscribe from the mailing list.


Reply via email to