Boost Threaded Windows App Ported to Linux

I wrote an application a short while ago utilizing the threading capabilities provided by the Boost library. It was written for Windows, on Windows using Visual Studio C++. After recompiling Boost for Linux, setting up all the necessary includes, linking required libraries, and fixing the little semantics that produced errors when compiling, I was finally able to build a working executable. This app is a terminal program, and when I ran it with the -h flag, it printed my help message perfectly. However, when I tried running the app that used the Boost threads, it would either seg fault or run into a problem printing out some really strange, cryptic text to the console.

My application is just fine, it runs great on Windows. The only thing I can think of that might cause this is that I have the boost thread 1.35 package installed in Debian, and I compiled using 1.38. however, there are no updated boost packages for Debian as of now.
Windows is, for some reason unknown to me, somewhat more resilient to segmentation faults. It's likely you had the bug all along, but it didn't manifest until you ran the program on Linux.

I would suggest Valgrind as a memory debugger. It gave me great results.
Very interesting, I always thought Linux held itself to better design practices than Windows did. One would think if this were true, you'd have less of a problem with things like segfaults. I'm probably wrong; I'd like to think I am.

Thanks for the information, I'm profiling now.
Well, if you think about it, it's better if the OS crashes the program as soon as the segmentation fault occurs. Whether the bug manifests or not, it's still a bug and can potentially produce a lot of damage. If you immediately realize some change you made produced a bug you're likely to find it faster than if it's been three months and there's 10k LOC to choose from.
Right that's what I was thinking too. Maybe Linux hastily ends programs that are segfaulting as a way of preventing more serious problems from occurring, and forcing the programmer to write better code. In that case, the design of Linux would be superior.

EDIT: Holy freaking crap, I can't believe it. I ran my app through valgrind, and it's running about one percent of it's normal speed, but it's functioning as it should; it's not segfaulting. The threads are working together, and the proper output is being printed to the console. I don't know if it's valgrind simply keeping the application chugging past the segfaults or what, but it's running like it should. (Albeit, very slowly.)
Last edited on
In that case, I would check for race conditions in my threads.
Topic archived. No new replies allowed.