# Crashing!

**URL:** <https://librepcb.discourse.group/t/crashing/570>\
**Category:** Help\
**Created:** [August 21, 2023, 5:19am UTC](https://librepcb.discourse.group/t/crashing/570 "2023-08-21T05:19:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![4Springs](https://avatars.discourse-cdn.com/v4/letter/4/ee59a6/32.png) [@4Springs](https://librepcb.discourse.group/u/4Springs)\
**Post date:** [August 21, 2023, 5:19am UTC](https://librepcb.discourse.group/t/crashing/570/1 "2023-08-21T05:19:44Z")

</div>

I’m up to the part where I’m placing components with the Board Editor.  
LibrePCB has been very stable up until now, but suddenly it crashed! All windows gone with no explanation.  
I opened the software again and selected my project. I received a dialog box asking me whether to revert to the last saved copy, and I said yes. This gave me a copy from a while ago, and I was able to continue on.  
But it wasn’t long before it crashed again. Then again, and again.  
Then I had this problem:

 ![image](https://global.discourse-cdn.com/free1/uploads/librepcb1/original/1X/f1c4ad299d1a3ee5ca40cc1ad27e9077da486313.png)  
Some of my components have moved far above my board. I couldn’t zoom into them, they seemed to be off the edge and I couldn’t scroll over to them. So I figured out that I could highlight them using the search function (I knew their names), then choose properties from the menu and change their coordinates.  
This helped me work out what was wrong - I’d been placing these components by typing in the coordinates:  
 ![image](https://global.discourse-cdn.com/free1/uploads/librepcb1/original/1X/a17d6d3176903a63a052c7b7a7e1600b13a502af.png)

Notice that my Y position is in mils. I changed to mils so that I could easily calculate the positions of my components on the grid.  
But when I started again after the crash, the Y pos had changed to mm. The component ZD4 was at 3625 mm, not 3625 mils. I don’t know whether this contributed to the crashes, or was just a side-effect of them.

I’m not sure if any of this would help you, but I’ll keep on going and save often. Let me know if there is any more information that could help figure out what is going on.  
I’m using Ubuntu 20.04

---

<div class="post-metadata">

**Author:** ![4Springs](https://avatars.discourse-cdn.com/v4/letter/4/ee59a6/32.png) [@4Springs](https://librepcb.discourse.group/u/4Springs)\
**Post date:** [August 21, 2023, 6:55am UTC](https://librepcb.discourse.group/t/crashing/570/2 "2023-08-21T06:55:50Z")

</div>

I figured this out!  
Well I figured something out, it may be the source of the crash. Here’s what I found:

I’ve been using mils to place components. When I place a component somewhere on the board, I then go into the properties and change the X and Y coordinates as needed. Here’s an example of a component placed on the board:

 ![image](https://global.discourse-cdn.com/free1/uploads/librepcb1/original/1X/d1d535fa5445e7e991f272ede04d8cf1d20b4bed.png)  
It’s using mils, since that is what I’ve set it to.

If I move the component ‘below the line’, then Y goes negative, like this:

 ![image](https://global.discourse-cdn.com/free1/uploads/librepcb1/original/1X/9af9152195713a6470e89859808cee7d3de664e1.png)

But if I move it to position Y=0, look what happens:

 ![image](https://global.discourse-cdn.com/free1/uploads/librepcb1/original/1X/9ead674226bd40f3e2d2df5e3d186b5f2e214e93.png)  
At zero, Pos. Y has now gone to mm rather than mils.

I think the crashing was happening because I moved my components to Y=0 first, then entered in my value, not realising that it had changed to mm. So I was entering 6000mm, and it didn’t handle this very well.

---

<div class="post-metadata">

**Author:** ![ubruhin](https://avatars.discourse-cdn.com/v4/letter/u/c89c15/32.png) [@ubruhin](https://librepcb.discourse.group/u/ubruhin)\
**Post date:** [August 21, 2023, 7:20am UTC](https://librepcb.discourse.group/t/crashing/570/3 "2023-08-21T07:20:24Z")

</div>

Oh, thanks for this detailed problem description, I’m able to reproduce it!

Indeed there are two issues:

- The unit unintentionally switches to millimeter
- Very large x/y numbers cause a crash

I’ll take care of them…

---

<div class="post-metadata">

**Author:** ![ubruhin](https://avatars.discourse-cdn.com/v4/letter/u/c89c15/32.png) [@ubruhin](https://librepcb.discourse.group/u/ubruhin)\
**Post date:** [August 21, 2023, 9:19am UTC](https://librepcb.discourse.group/t/crashing/570/4 "2023-08-21T09:19:54Z")

</div>

Update:

The problem with the unit is fixed in the next release (_small secret: release date will be today_ 😁 ).

For the actual crash I opened an issue to keep this in mind:

> <https://github.com/LibrePCB/LibrePCB/issues/1204>
>
> \##### VERSION / OS / ENVIRONMENT
> \<!-- Paste the exact application version, oper…ating system and environment used
> below. You can copy all needed information directly from the "Help-\>About"
> dialog, tab "Details". Alternatively you could copy the version numbers from the
> console output (the first few lines). --\>
> 
> \`\`\`
> LibrePCB Version: 0.1.7
> Git Revision: ba553c6
> Build Date: 2022-10-03T08:30:22
> Qt Version: 5.15.2 (built against 5.15.2)
> CPU Architecture: x86\_64
> Operating System: Manjaro Linux
> Platform Plugin: xcb
> TLS Library: OpenSSL 1.1.1l 24 Aug 2021
> \`\`\`
> 
> \##### SUMMARY
> 
> 
> The application crashes when entering very large X/Y values in a board (probably also in other editors). See original bug report here: https://librepcb.discourse.group/t/crashing/570
> 
> \##### STEPS TO REPRODUCE
> 
> 
> Set a device X coordinate to e.g. 6000 mm.
> 
> \##### EXPECTED RESULTS
> 
> 
> The device is moved to X=6000mm.
> 
> \##### ACTUAL RESULTS
> 
> 
> LibrePCB crashes.
> 
> \##### ADDITIONAL INFORMATION
> 
> Seems to be happening because an integer overflow happens during calculations of distance (involving the calculation of \`x^2 + y^2\`), at least an assert fails - probably more goes wrong since the release build crashes as well.
> 
> Not sure how to fix that properly. Maybe any user input should be clipped to a reasonable range (e.g. +/- 1000mm, if this is safe) to have enough reserve for further calculations. But maybe the limitation should be in the data layer instead of in the GUI :thinking: 
> 
> Just failing during the calculations is not really nice as this could happen some time later in different actions (e.g. during DRC). 
> 
> An alternative might be to perform the calculations with floating point operations if the numbers are large, but that feels quite ugly and leads to non-deterministic results...
