Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can builds from the same source code yield functionally different executables?

Recently, a colleague of mine said something along these lines: "consecutive APKs (executables) produced by build server from the same source code might not be the same". The context for this discussion was whether QA performed on build X also applies to build Y, which was performed by the same build server (configured the same way) from the same source code.

I think that generated executables might not be identical due to various factors (e.g. different timestamp), but the question is whether they can be functionally different.

The only scenario, that I can think of, in which the same source code could produce different functionality is that of multi-threading issue: in case of incorrect synchronization of multi-threaded code, different re-ordering/optimization actions performed at compile time could affect this poorly synchronized code and change its functional behavior.

My questions are:

  1. Is it true that consecutive builds performed by the same build server from the same source code can be functionally different?
  2. If #1 is true, are these differences limited to incorrectly synchronized multi-threaded code?
  3. If #2 is false, what are the other parts that can change?

Links to any related material will be appreciated.

like image 499
Vasiliy Avatar asked Feb 20 '16 19:02

Vasiliy


Video Answer


1 Answers

It's certainly possible in a few cases. I'll assume you are using Gradle to build your Android app.

Case 1: You are using a 3rd party dependency that's included with a version wildcard, such as:

compile somelib.1+

It's possible for the dependency to change in this case, which is why it's highly recommended to use explicit dependency versions.

Case 2: You're injecting environment information into your app using Gradle's buildConfigFields. These values will be injected into your app's BuildConfig class. Depending on how you use those values, the app behavior could vary on consecutive builds.

Case 3: You update the JDK on your CI in-between consecutive builds. It's possible, though I'd assume highly unlikely, that your app behavior could change depending on how it's compiled. For example, you might be hitting an edge case in the JDK that gets fixed in a later version, causing code that previously worked before to act differently.

I think this answers your first question and second question.

edit: sorry, I think I missed some important info from your OP. My case 2 is an example of your e.g. different timestamp and case 3 violates your configured the same way. I'll leave the answer here though.

like image 105
telkins Avatar answered Sep 21 '22 14:09

telkins