Application runs in ArchLinux fine, but doesn't work in Ubuntu

Hey. I have a little C++ program, that works perfectly on ArchLinux. However, when I try to run it on my Ubuntu Virtual Machine, it throws an error.

The problem is that error is not some dependency error or something. It is a freaking logical error.

terminate called after throwing an instance of 'std::length_error'
what(): basic_string::_M_create
Aborted (core dumped)


The code:
https://github.com/PonasKovas/pasman/blob/master/main.cpp
* Warning! It is very poorly written. *
Also there are more files, but they're from the internet. The main.cpp is the only file I wrote myself.

All help is very appreciated.
Searching for "std::length_error":
http://www.cplusplus.com/reference/stdexcept/length_error/

Who does throw it?
"basic_string::_M_create" tells that it is a std::string in your code.


You could enclose suspects into try-catch blocks to debug which of them throws.


You have code like string space((w.ws_col - 64)/2, ' ');
What if w.ws_col < 64?
Is string fubar( -1, ' ' ); healthy?
Just use a debugger and it will tell you the exact location where the exception is thrown.

If you have gdb installed you just run your program with gdb ./yourprogram, then run, and then when it crashes you just type bt and it will print a full stack trace (assuming you have compiled with debugging symbols turned on, i.e. used the -g compiler flag).
Last edited on
@keskiverto That might be what's causing it. On my virtual machine I set the resolution to 640x400 to reduce lag, so the terminal definetely didnt have 64 columns... I will check it now.
Yep. When I lowered the terminal window size on ArchLinux, it also threw the error.

All fixed now.

Also if anyone has the time I would really appreciate if you tested my application on your OS.
Last edited on
Topic archived. No new replies allowed.