ARMmbed / ARMmbed/mbed-cli

Misleading AttributeError: '_queue.SimpleQueue' object has no attribute 'queue' when compiler fails

Open
#905 11 comments 0 reactions 0 assignees View on GitHub
Jira status: OPEN mirrored
Dominant language
Python
Stars
339
Forks
187
PR merge metrics
No merged PRs in 30d

Description

There is completely misleading error message when underlying command fails. This is easiest to reproduce by adding invalid commandline switch to gcc profile (eg. open mbed-os/tools/profiles/develop.json and add "-invalid-flag" to "common" array) and then building project with GCC.

The example output without verbose flag is:
```
$ mbed compile
Building project mbed-os-example-blinky (DISCO_F746NG, GCC_ARM)
Scan: mbed-os-example-blinky
Compile [ 0.5%]: mbed_tz_context.c
[ERROR] '_queue.SimpleQueue' object has no attribute 'queue'
[mbed] WARNING: If you're using Python 3 with Mbed OS 5.8 and earlier versions, Python errors will occur when compiling, testing and exporting
---
[mbed] ERROR: "c:\python37\python.exe" returned error.
Code: 1
Path: "C:\work\mbed\mbed-os-example-blinky"
Command: "c:\python37\python.exe -u C:\work\mbed\mbed-os-example-blinky\mbed-os\tools\make.py -t GCC_ARM -m DISCO_F746NG --source . --build .\BUILD\DISCO_F746NG\GCC_ARM"
Tip: You could retry the last command with "-v" flag for verbose output
---
[mbed] WARNING: Using Python 3 with Mbed OS 5.8 and earlier can cause errors with compiling, testing and exporting
---
[mbed] Working path "C:\work\mbed\mbed-os-example-blinky" (program)
--
```

This misleading error message is made clear by using `mbed compile -v`
```
[DEBUG] Output: arm-none-eabi-g++: error: unrecognized command line option '-invalid-flag'; did you mean '-Winvalid-pch'?
Traceback (most recent call last):
File "C:\work\mbed\mbed-os-example-blinky\mbed-os\tools\toolchains\mbed_toolchain.py", line 523, in compile_queue
res['command']
File "C:\work\mbed\mbed-os-example-blinky\mbed-os\tools\toolchains\mbed_toolchain.py", line 650, in compile_output
raise ToolException(stderr)
tools.utils.ToolException: arm-none-eabi-g++: error: unrecognized command line option '-invalid-flag'; did you mean '-Winvalid-pch'?
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\work\mbed\mbed-os-example-blinky\mbed-os\tools\make.py", line 76, in wrapped_build_project
src_dir, build_dir, mcu, *args, **kwargs
File "C:\work\mbed\mbed-os-example-blinky\mbed-os\tools\build_api.py", line 596, in build_project
objects = toolchain.compile_sources(resources, sorted(resources.get_file_paths(FileType.INC_DIR)))
File "C:\work\mbed\mbed-os-example-blinky\mbed-os\tools\toolchains\mbed_toolchain.py", line 459, in compile_sources
return self.compile_queue(queue, objects)
File "C:\work\mbed\mbed-os-example-blinky\mbed-os\tools\toolchains\mbed_toolchain.py", line 527, in compile_queue
if p._taskqueue.queue:
AttributeError: '_queue.SimpleQueue' object has no attribute 'queue'
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the failure by adding "-invalid-flag" to the GCC profile's "common" array and running `mbed compile -v`. Start in mbed-os/tools/toolchains/mbed_toolchain.py at compile_queue and compile_output, then verify that a failed compiler command reports the underlying ToolException rather than the `_queue.SimpleQueue` AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.