1

I'm specifically concerned about utarray version 2.0.2 vs. 1.9.6. (The most recent copyrights being 2017 and 2012, respectively).

I need to add uthash.h to an existing project that makes use of utarray.h, and would rather both these headers come from the same version/commit, so I'm considering replacing the older utarray.h with the newer.

I should note I'm not terribly concerned about compile-time incompatibilities, such as name changes and the like. My main concern would be run-time breakages.

zzxyz
  • 2,953
  • 1
  • 16
  • 31

2 Answers2

1

If you look at utarray.h, you'll see that all it defines are macros, a few static functions, and some typedefs; there are no public symbols, so everything should be restricted to the current compilation unit.

In other words, yes, as long as you don't include both headers in the same file (which would likely cause a compile-time error) or expose it in your public API you should be safe.

That said, the answer to the question in your title is "no"; incompatible changes in the API break backward compatibility. But with the restrictions you mention in the body you should be okay.

nemequ
  • 16,623
  • 1
  • 43
  • 62
  • I may be misunderstanding your answer, but my plan is to "replace the older utarray.h with the newer", not have two versions lying around. I know from experience it's quite easy to blow up these macros with incorrect params that are not detected by the compiler, and I'm worried the old utarray.h client code will experience this. – zzxyz Feb 08 '18 at 21:12
  • Nope, I was misunderstanding your question. My answer was that it's safe to have both versions setting around as long as you're not trying to use them both in the same compilation unit. If it were safe to just swap out the 1.x header for the 2.x header there probably wouldn't have been a bump in the major version (that's usually what a major version bump signals). You may not be using the part of the API that changes, so the answer is probably "maybe". – nemequ Feb 08 '18 at 21:19
  • We have the multiple versions thing going on with msgpack already, and it becomes a nightmare in practice. But...I may just continue using the old version of utarray.h with the new version of uthash.h based on this.. – zzxyz Feb 08 '18 at 21:23
0

A rare but 100% reproducible stack corruption issue around usage of utarray caused me to attempt an upgrade, of JUST utarray.h, but across the board at my company.

The short answer is NO, it is not 100% backward compatible. But it's very close.

The longer answer is for our applications, the required changes were extremely trivial, basic usage does not change, and the stack corruption issue seems to have gone away. It also seems to be interacting well with other, older headers, such as uthash.

The only interface change I found was a _UNUSED_ macro for hushing gcc warnings changed to UTARRAY_UNUSED. Everything else seems to be bug fixes.

Edit: I'm not naive enough to be even remotely confident that 1.9.6 had an issue causing our stack corruption, but I'm not totally dismissing the possibility after carefully stepping through the same 10 lines of code in the debugger for about 2 hours, and watching every variable be correct.

zzxyz
  • 2,953
  • 1
  • 16
  • 31
  • TBH when you have this kind of problems you want first to completely understand the issue, and then fix it - and 2 hours of source level debugging is often unfortunately not enough for this kind of problems. Changing stuff around and seeing that it goes away isn't guarantee of anything really, it is definitely possible that you just moved stuff around and swept the actual problem under the carpet. Trading a reproducible issue with a non reproducible one isn't a great deal. – Matteo Italia Mar 08 '18 at 18:59
  • @MatteoItalia - It's still reproducible with `git checkout` if I ever get time to look into it again :) (I won't) – zzxyz Mar 08 '18 at 23:18
  • @MatteoItalia I just discovered valgrind and you’ll be absolutely shocked to hear it thinks this code is still problematic:) – zzxyz Mar 28 '18 at 02:24
  • 1
    OMG who could have said! Seriously: let also UBsanitizer have a stab at it, you'll be pleasantly surprised. – Matteo Italia Mar 28 '18 at 05:18