Compilation seems to succeed, but binary does not run correctly

Bug #1782083 reported by rew
18
This bug affects 2 people
Affects Status Importance Assigned to Milestone
gcc-arm-none-eabi (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

I found that none of my projects worked anymore.

When I recompiled on ubuntu16.04 (my last machine at that distribution) and downloaded the binary, it worked again.

It seems to be the toolchain that is defective.

I think I'm going to try the suggestion from: https://github.com/ArduPilot/ardupilot/issues/8663

Revision history for this message
rew (r-e-wolff) wrote :

Update: that worked to get my project to show up as an USB device again. (all the innards have now been removed in an attempt to rule things out, so now back to re-inserting the innards of my project).

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in gcc-arm-none-eabi (Ubuntu):
status: New → Confirmed
Revision history for this message
Maxime JOURDAN (xanthio) wrote :

I got the same issue for a professional project with Bionic package. Compile is fine but program crashes on the target.

Investigations revealed that the crash come from the use of atan2f in my program. the use of atanf trigger exactly the same issue.

The issue is not present with Xenial package nor with Version 7-2018-q2 from ARM website.

Revision history for this message
rew (r-e-wolff) wrote :

I decided to try to trace this down to the source line that compiles differently between the two distributions causing the difference in behavior.....

I failed.

The problem is with the linker. linking the executable on xenial from the objects compiled on bionic creates a working binary and linking the objects created on xenial with the linker on bionic results in a non-working binary.

Oh...... There is an old bug where the linker would forget to or in the "this is thumb" flag when linking thumb code. (A jump in ARM is to a target address, but as instructions are always at least 16 bit wide, the bottom bit is in essence always zero. This is used to signal "this is thumb code" when that bit is high. So when jumping to the function at address 0x8000120, the actual target should resolve to 0x8000121 to indicate it is arm-thumb code. My processor is thumb-only and will fault on a jump that resolves to 0x8000120.)

I will check if this is the case and report back.
(If this is in fact the bug, I reported this years ago. 2010-2014 era....)

Revision history for this message
rew (r-e-wolff) wrote :

Update;
No confirmation yet. Heisenbug: I managed to get the bug to disappear (the executable works normally) when I run it attached to the debugger. Sigh.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.