pyocd / pyocd/pyOCD

pyocd-gdbserver crash when disconnecting serial port

Open
#309 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog bug
Dominant language
Python
Stars
1.5k
Forks
560
Avg merge
1h 41m
Merged PRs (30d)
3

Description

If I start pyocd-gdbserver, run application and open serial port connection to mbed (K64F) board everything seems work as expected, but if I then disconnect serial port pyocd-gdbserver crashes with Unhandled exception in handleMsg.

See traceback below:

2017-05-17T11:55:03.547Z - warn: pyocd:stderr:  ERROR:root:Unhandled exception in handleMsg: 
2017-05-17T11:55:03.547Z - warn: pyocd:stderr:  Traceback (most recent call last):
2017-05-17T11:55:03.547Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/gdbserver/gdbserver.py", line 426, in handleMsg
2017-05-17T11:55:03.547Z - warn: pyocd:stderr:      return self.getRegisters(), 0
2017-05-17T11:55:03.547Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/gdbserver/gdbserver.py", line 868, in getRegisters
2017-05-17T11:55:03.547Z - warn: pyocd:stderr:      return self.createRSPPacket(self.target_facade.getRegisterContext())
2017-05-17T11:55:03.547Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/gdbserver/context_facade.py", line 54, in getRegisterContext
2017-05-17T11:55:03.547Z - warn: pyocd:stderr:      vals = self._context.readCoreRegistersRaw(reg_num_list)
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/debug/context.py", line 117, in readCoreRegistersRaw
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:      return self._core.readCoreRegistersRaw(reg_list)
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/coresight/cortex_m.py", line 655, in readCoreRegistersRaw
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:      reg_cb = self.readMemory(CortexM.DCRDR, now=False)
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/coresight/cortex_m.py", line 397, in readMemory
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:      result = self.ap.readMemory(addr, transfer_size, now)
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/coresight/ap.py", line 162, in readMemory
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:      self.write_reg(AP_REG['TAR'], addr)
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/coresight/ap.py", line 103, in write_reg
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:      self.dp.writeAP((self.ap_num << APSEL_SHIFT) | addr, data)
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/coresight/dap.py", line 259, in writeAP
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:      self.link.write_reg(ap_reg, data)
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 635, in write_reg
2017-05-17T11:55:03.548Z - warn: pyocd:stderr:      self._write(dap_index, 1, request, [value])
2017-05-17T11:55:03.549Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 840, in _write
2017-05-17T11:55:03.549Z - warn: pyocd:stderr:      self._send_packet()
2017-05-17T11:55:03.549Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 783, in _send_packet
2017-05-17T11:55:03.549Z - warn: pyocd:stderr:      self._read_packet()
2017-05-17T11:55:03.549Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 738, in _read_packet
2017-05-17T11:55:03.549Z - warn: pyocd:stderr:      decoded_data = cmd.decode_data(raw_data)
2017-05-17T11:55:03.549Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 419, in decode_data
2017-05-17T11:55:03.549Z - warn: pyocd:stderr:      data = self._decode_transfer_data(data)
2017-05-17T11:55:03.549Z - warn: pyocd:stderr:    File "/Users/user01/git/github/mbedmicro/pyOCD/pyOCD/pyDAPAccess/dap_access_cmsis_dap.py", line 318, in _decode_transfer_data
2017-05-17T11:55:03.549Z - warn: pyocd:stderr:      raise DAPAccessIntf.TransferError()
2017-05-17T11:55:03.551Z - warn: pyocd:stderr:  TransferErro

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash by disconnecting the serial port while pyocd-gdbserver is running, then trace the request from pyOCD/gdbserver/gdbserver.py through context_facade.py, debug/context.py, coresight/cortex_m.py, and pyDAPAccess/dap_access_cmsis_dap.py. Determine how the reported TransferError should be handled so the server does not crash, and verify that the disconnect scenario completes without an unhandled exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devtools, embedded-iot
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.