Jump to content

  • Log In with Google      Sign In   
  • Create Account

Are segfaults normal when project hasn't been cleaned for a while?

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
7 replies to this topic

#1   Members   


Posted 14 January 2013 - 03:02 AM

Hi everyone,

I'm working on a project from three machines, using one machine most of the time.
Yesterday, after adding a new member variable to a class, the project compiled but then crashed.
Usually, I wouldn't hesitate to take the blame.

It's very-very rare I make the compiler or environment behave wrong.
I code stupid, make things easy for myself when possible.

I tried debugging to find the source of the segfault. I found that it seemingly occurred in std::map::insert(val, key), and traced upwards. Everything had been initialized. Val referenced something created elsewhere, I thought it looked good. Key was a copy since the parameter. I hadn't touched this area of my code for over two months...
There were no dangling pointers (no pointers, even) to be found in my main units, so I thought it had something to do with the member variable. (Being the last change I committed, this should be the prime suspect)

The class that I added the variable to contained an object which in turn contained the std::map, so I thought to myself, that maybe the change in the header file didn't trigger a build of new .os that should depend on it. When I created my own build tool, I didn't check the headers for modifications, and unless I changed the implementation file too, I'd often end up with having to clean build, or everything would crash.

Sure enough, a clean build fixed the error. But is Netbeans supposed to miss a significant change like a new member variable, without recompiling the unit+dependent units?

Do you guys experience this too from time to time? It's been weeks since I last encountered a segfault,
and now I'm worried that perhaps I'm doing something wrong.

Edited by SuperVGA, 14 January 2013 - 03:05 AM.

#2   Members   


Posted 14 January 2013 - 03:14 AM

In my experience, IDE:s in general are far from perfect.

I always do a clean and recompile as a first measure when I encounter a strange bug.

#3   Members   


Posted 14 January 2013 - 03:47 AM

Anything with an "edit and continue" type feature I've found will sometimes miss-patch the partial build.  It's rather flaky as to when I've seen this type of thing happen, but it's very annoying when it does.

#4   GDNet+   


Posted 14 January 2013 - 04:30 AM

in my experience, a seg-fault cropping up/disappearing with a clean is resonate of a much deeper problem in the code base.


This is not to say it very well might be an issue with a bad build, but in general, i've almost always discovered their to be an actual flaw in my code somewhere after heavy analyzing(something that only cropped up because the compiler didn't null all my pointers(and i forgot to explicity set a pointer to null) for me for some reason, or was allowing buffer-overflow's that didn't cause immidiate crash's)


edit after L. Spiro's/Karsten_'s posts, i'd like to point out that i only use a single machine for compilation, and i use VS 2010, which auto-detects header changes, and appropriately re-compiles the obj's that include the headers, which is probably why i more often experience such things in form of actual bugs, than bad build's.

Edited by slicer4ever, 14 January 2013 - 06:59 AM.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#5   Members   


Posted 14 January 2013 - 06:14 AM

That’s not been my experience (to slicer4ever).


Doing a clean build removes .OBJ files from different versions of compilers and this can have a profound effect on the stability of the resulting .EXE.

I even have the same compiler on both my Windows XP and Windows 7 installs, same service packs, etc.  But when I switch between Windows XP and Windows 7 I really have to do a clean or I am guaranteed to get segment faults and other strange behavior.

Many times in the most isolated areas I have been able to prove the code was correct.  A clean rebuild became part of my routine and I no longer suspect any underlying issues with the code.


As for the original poster, if you work with your code between different machines, save yourself some hassle and get into the habit of cleaning each time you copy the code and project to a new machine.  Once again, for me, failure to do so always results in some kind of crazy run-time crash that makes no sense.



L. Spiro

Edited by L. Spiro, 14 January 2013 - 06:16 AM.

#6   Members   


Posted 14 January 2013 - 06:54 AM

Usually IDEs deal with this sort of thing using .d files.


Basically when you change a header and add something like an std::string to it, you really should compile every unit (.cpp file) that has a dependence on that header.


I believe this is because otherwise the space for the new variable is not reserved properly from those objects.


I have this issue when using Makefiles but rather than fix the issue (making the build system quite a bit more complex), I just detect whether a header has changed and rebuild the whole thing.

http://tinyurl.com/shewonyay - Thanks so much for those who voted on my GF's Competition Cosplay Entry for Cosplayzine. She won! I owe you all beers :)

Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.

#7   Members   


Posted 14 January 2013 - 07:37 AM

I'm with LSpiro here, have frequently had issues that were nothing to do with code and simply due to the IDE/Build System failing to rebuild an object file that it should have.


Qt's PRO system suffers from this quite often. Guess it is hard to get a dependency system right.

#8   Members   


Posted 14 January 2013 - 11:10 AM

Thanks for your input everyone. Actually, LSpiro and Aaardvajk,
I don't even have my obj/ shared. The only thing I did of those sorts was to not clean build for a long time.
On my repo, i only have src, doc and bin/ (for scripts and assets)
And thus no obj + dist files are shared.
I have my makefiles, .nbproject (and perhaps d files as well), though.

Perhaps it tends to be a makefile-related thing?
Slicer4Evers use of MSVC could support this...

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.