LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-03-2011, 02:03 AM   #1
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,622
Blog Entries: 29

Rep: Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896
Code committed in repository doesn't work the next day!


It has happened with me before too! Few months back while working on Priority queue in C language, I successfully compiled the code and it gave the desired outputs, I showed the running code to my other seniors and committed it to the repository at 21:00 (I was in the office till late night), next day my boss asked to show the running code, and it didn't work!!! I updated from the repository whatever I had committed but still nothing worked?? My boss was smiling thinking I had lied last night!

and then on this Saturday, my boss fixed a bug and committed to the repository and asked me to checkout which I did today morning, and when I ran the code it didn't work??? I stared at him and smiled, he swore that he had fixed the bug, and then he tried on his own machine, thinking I had messed up something on mine, but that was a futile effort and he banging his head to the walls now!

Valgrind didn't show any causes of concern both the times, anyone faced the situation before?
 
Old 01-03-2011, 03:47 AM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by Anisha Kaul View Post
It has happened with me before too! Few months back while working on Priority queue in C language, I successfully compiled the code and it gave the desired outputs, I showed the running code to my other seniors and committed it to the repository at 21:00 (I was in the office till late night), next day my boss asked to show the running code, and it didn't work!!! I updated from the repository whatever I had committed but still nothing worked?? My boss was smiling thinking I had lied last night!

and then on this Saturday, my boss fixed a bug and committed to the repository and asked me to checkout which I did today morning, and when I ran the code it didn't work??? I stared at him and smiled, he swore that he had fixed the bug, and then he tried on his own machine, thinking I had messed up something on mine, but that was a futile effort and he banging his head to the walls now!

Valgrind didn't show any causes of concern both the times, anyone faced the situation before?
You and your boss committed code written/fixed by you/him, but not the compiler, linker, libraries. I.e. if you are compiling code on a different machine, it can fail.

Also, the code may have some kind of race condition - in such a case its proper operation is a random event.

Or use of uninitialized values - '-Wall -Wextra' 'gcc' switches are a must.
 
Old 01-03-2011, 03:52 AM   #3
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,622
Blog Entries: 29

Original Poster
Rep: Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896
I did think on these issues before posting here,

We used same version of Kdevelop and OpenSuse for compiling and running the code and in the second case both of our machines are 64 bit!
 
Old 01-03-2011, 04:00 AM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by Anisha Kaul View Post
I did think on these issues before posting here,

We used same version of Kdevelop and OpenSuse for compiling and running the code and in the second case both of our machines are 64 bit!
And the trivial thing - never trust a repository (the SW or configuration can be buggy). Always maintain a local copy, and if you can be accused of cheating (expect you can) have the code stored as, say, an Email attachment on company mail server - in such a case it's "write once" storage (i.e. you can not modify the file on company mail server once it's written), so you can show everybody that you did change the code.
...
On my machine (I am also running SUSE) there are rare 'gcc' crashes under heavy load, and the statement is true for both stock 'gcc' and self-built 'gcc' of various versions.

I can't reproduce the bug, i.e. relaunching the same command with the same input files and the same 'gcc' produces normal results.

I mean, there can be some kind of random failure, but you'll have to dig this.
 
Old 01-03-2011, 04:10 AM   #5
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,622
Blog Entries: 29

Original Poster
Rep: Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896
Thanks for your input, now I am forced to keep the local copies on the code on my computer but in the second case, I somehow feel, the repository is not at the fault, since my boss went to his seat and ran the same code from his computer, and it didn't work today!

I think there must be some kind of memory error involved somewhere which Valgrind doesn't show??
 
Old 01-03-2011, 04:47 AM   #6
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by Anisha Kaul View Post
Thanks for your input, now I am forced to keep the local copies on the code on my computer but in the second case, I somehow feel, the repository is not at the fault, since my boss went to his seat and ran the same code from his computer, and it didn't work today!

I think there must be some kind of memory error involved somewhere which Valgrind doesn't show??
Are you sure the repository is not at fault ? For example, if repository SW just somehow ignores checkin, the the code in the repository is not updated.

There may be odd things due to NFS problems because of network problems - depends on how NFS is configured. Most likely your repository is on a separate machine.

You really have to make sure that the code checked out from the repository does contain the changes you expect it to have.
 
Old 01-03-2011, 04:54 AM   #7
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,622
Blog Entries: 29

Original Poster
Rep: Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896Reputation: 896
I do agree with you on the repository issue but still (if the repository in not in picture) the change which made the code work two days back on a computer should make the code work again if run 2 days later on the same computer! That is the issue here.
 
Old 01-03-2011, 08:29 AM   #8
dugan
Senior Member
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 4,630

Rep: Reputation: 1429Reputation: 1429Reputation: 1429Reputation: 1429Reputation: 1429Reputation: 1429Reputation: 1429Reputation: 1429Reputation: 1429Reputation: 1429
Check out the broken revision that you showed your boss, and diff it against your local copy of the tested, working code that you checked in. I bet they will be different.

The standard solution to this is to set up continuous integration.

Committing to a version control repository commits only the changes that you made since your last commit. If you've commit a change to file A and someone else committed a change to file B, then the repository would contain your changes to file A and your co-worker's changes to file B. You would have tested your work on file A and your co worker would have tested her work on file B. The project in the repository, which depends on both files, would be untested. The solution to is to use a continuous integration tool (like Hudson, Cruise Control, etc) to automatically build, unit test and lint the code in the repository after each commit.

Furthermore, if you mess-up a check-in by, say, forgetting to mark a file for "add", you want the continuous integration software to catch you. Not your boss.

In any case, you should always check out the repository after each commit and try to build it. Have unit tests to catch runtime errors, and design your software's architecture to make unit testing both possible and efficient. To give an extreme example of what not to do, putting XML parsing code in a constructor makes the XML parsing code impossible to unit test. In the case of your priority queue, putting in the inputs and checking the output should have been done by a unit test.

Finally, some version control systems have more of a problem with this than others (I remember reading that Mercurial has less of a problem with this than Subversion, for example).

EDIT: with this post, my post count is exactly 1337!

Last edited by dugan; 01-03-2011 at 09:40 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why doesn't this repository address work? newbiesforever Linux - Software 10 08-04-2009 03:14 AM
LXer: Microsoft Releases Code for Windows 95, 98, Me and MS-DOS For One Day Only! LXer Syndicated Linux News 0 04-01-2008 01:11 PM
Does anyone know of a web based private source code repository HGeneAnthony Linux - Software 3 04-12-2006 02:54 PM
import fail to put code to the repository powah Linux - Software 0 10-25-2005 02:09 PM


All times are GMT -5. The time now is 10:46 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration