caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] inconsistent assumptions over implementation Printf
@ 2015-06-23 19:52 Richard W.M. Jones
  2015-06-23 20:41 ` Török Edwin
  0 siblings, 1 reply; 4+ messages in thread
From: Richard W.M. Jones @ 2015-06-23 19:52 UTC (permalink / raw)
  To: caml-list

This seems like a rather basic question, but here goes.

For a long time in Fedora we've used RPM dependencies to enforce that
the "inconsistent assumptions" error does not occur for end users.
This means encoding the OCaml version + MD5 hash of each interface.
For example:

  $ rpm -q --provides ocaml-runtime
  ...
  ocaml(Printf) = eb49a17645c5ea2dd298430a3c986186
  ...
  ocaml(runtime) = 4.02.2

With the move from 4.02.2+rc1 to 4.02.2 final, we've suddenly started
to see:

  Error: Files /usr/lib64/ocaml/gettext/gettextBase.cmxa
       and /usr/lib64/ocaml/stdlib.cmxa
       make inconsistent assumptions over implementation Printf

The ocaml(runtime) version string didn't change, so we're relying
solely on the ocaml(Printf) dependency to prevent this.  According to
my understanding the above error "cannot" happen, not least because
Printf didn't change its interface between -rc1 and final.

ocamlobjinfo from the relevant libraries:

  http://oirase.annexia.org/tmp/stdlib.cmxa.txt
  http://oirase.annexia.org/tmp/gettextBase.cmxa.txt

Can someone explain where my understanding is wrong?

Also - could we *please* make the error message more explanatory.
Printing out the mismatching MD5 hashes would be a good start.

Thanks,

Rich.

-- 
Richard Jones
Red Hat

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] inconsistent assumptions over implementation Printf
  2015-06-23 19:52 [Caml-list] inconsistent assumptions over implementation Printf Richard W.M. Jones
@ 2015-06-23 20:41 ` Török Edwin
  2015-06-25  7:58   ` Richard W.M. Jones
  0 siblings, 1 reply; 4+ messages in thread
From: Török Edwin @ 2015-06-23 20:41 UTC (permalink / raw)
  To: caml-list

On 06/23/2015 10:52 PM, Richard W.M. Jones wrote:
> This seems like a rather basic question, but here goes.
> 
> For a long time in Fedora we've used RPM dependencies to enforce that
> the "inconsistent assumptions" error does not occur for end users.
> This means encoding the OCaml version + MD5 hash of each interface.
> For example:
> 
>   $ rpm -q --provides ocaml-runtime
>   ...
>   ocaml(Printf) = eb49a17645c5ea2dd298430a3c986186
>   ...
>   ocaml(runtime) = 4.02.2
> 
> With the move from 4.02.2+rc1 to 4.02.2 final, we've suddenly started
> to see:
> 
>   Error: Files /usr/lib64/ocaml/gettext/gettextBase.cmxa
>        and /usr/lib64/ocaml/stdlib.cmxa
>        make inconsistent assumptions over implementation Printf
> 
> The ocaml(runtime) version string didn't change, so we're relying
> solely on the ocaml(Printf) dependency to prevent this.  According to
> my understanding the above error "cannot" happen, not least because
> Printf didn't change its interface between -rc1 and final.

The error message refers to the compiled *implementation* (cmx), not the interface.

> 
> ocamlobjinfo from the relevant libraries:
> 
>   http://oirase.annexia.org/tmp/stdlib.cmxa.txt
>   http://oirase.annexia.org/tmp/gettextBase.cmxa.txt
> 
> Can someone explain where my understanding is wrong?

The implementation hash for Printf is different in those two cmxa:

Implementations imported:
	04c9d8650cdb1dfb88a0138d7aa7f627	Printf
Implementations imported:	
	3f8359483c50f1154e7f110de488d53c	Printf

If you use ocamlobjinfo to track down the changed implementation hashes you end up in camlinternalFormat changing, which changed due to Sys changing,
which changed due to the (inlinable) version number changing:

-File /home/edwin/.opam/4.02.2+rc1/lib/ocaml/sys.cmx
+File /home/edwin/.opam/4.02.2/lib/ocaml/sys.cmx
 Name: Sys
-CRC of implementation: 0f8a319756ebc1cd7f8defc8ada059bb
+CRC of implementation: 68274db6c865f50a2652e53becb14c88
 Globals defined:
 	Sys
 Interfaces imported:
@@ -21,7 +21,7 @@
    29: const(-18); 30: const(-19); 31: const(-20); 32: const(-21);
    33: global(camlSys,33);
    34: function camlSys__catch_break_1066 arity 1 (closed) ->  _;
-   35: const("camlSys__2"="4.02.2+rc1"))
+   35: const("camlSys__2"="4.02.2"))


Now camlinternalFormat only uses Sys.max_string_length not Sys.ocaml_version, but the hash won't know that ...

> 
> Also - could we *please* make the error message more explanatory.
> Printing out the mismatching MD5 hashes would be a good start.
> 

Yeah, and a -r flag on ocamlobjinfo.

Best regards,
--Edwin


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] inconsistent assumptions over implementation Printf
  2015-06-23 20:41 ` Török Edwin
@ 2015-06-25  7:58   ` Richard W.M. Jones
  2015-06-26 21:27     ` Török Edwin
  0 siblings, 1 reply; 4+ messages in thread
From: Richard W.M. Jones @ 2015-06-25  7:58 UTC (permalink / raw)
  To: Török Edwin; +Cc: caml-list

On Tue, Jun 23, 2015 at 11:41:52PM +0300, Török Edwin wrote:
[...]

Thanks - I have filed a bug about generating better dependencies:

https://bugzilla.redhat.com/show_bug.cgi?id=1235561

> > Also - could we *please* make the error message more explanatory.
> > Printing out the mismatching MD5 hashes would be a good start.
> > 
> 
> Yeah, and a -r flag on ocamlobjinfo.

What would the -r flag do?

Rich.

-- 
Richard Jones
Red Hat

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] inconsistent assumptions over implementation Printf
  2015-06-25  7:58   ` Richard W.M. Jones
@ 2015-06-26 21:27     ` Török Edwin
  0 siblings, 0 replies; 4+ messages in thread
From: Török Edwin @ 2015-06-26 21:27 UTC (permalink / raw)
  To: Richard W.M. Jones; +Cc: caml-list

On 06/25/2015 10:58 AM, Richard W.M. Jones wrote:
> On Tue, Jun 23, 2015 at 11:41:52PM +0300, Török Edwin wrote:
> [...]
> 
> Thanks - I have filed a bug about generating better dependencies:
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=1235561

Do any of the advanced linker features in ocamlopt/ocamlc change the way ocamlobjinfo output should be used by packaging tools?
I see that -no-alias-deps adds '--------------------------------' to list of 'implementations imported' sometimes.
AFAICT this is properly ignored by the current rpm scripts, but I'm not familiar with how all the other linker features (packs, module aliases, rectypes, ...) work at the .cmx(a) level.

Perhaps there should be a 'hello-ocaml-dep' package that contains multiple inter-dependent library sub-packages exercising all these features.

For example should -safe-string usage be tracked by the package manager? OCaml itself doesn't complain now when the main application is linked with -safe-string, and
some module was compiled without it and ends up modifying the (immutable) strings, and I'm not sure whether that information exists in the .cmi/.cmx (should it?)

> 
>>> Also - could we *please* make the error message more explanatory.
>>> Printing out the mismatching MD5 hashes would be a good start.
>>>
>>
>> Yeah, and a -r flag on ocamlobjinfo.
> 
> What would the -r flag do?

Starting from  a given module recursively print the modules that are part of its interface/implementation hash, perhaps a better name would be --filter-recursive.
Of course you'd need to have both the old and new .cmx(a) around, in your case:
ocamlobjinfo /usr/lib64/ocaml/stdlib.cmxa  --filter-recursive=Printf >hashes1
ocamlobjinfo /path/to/4.02.2+rc1/stdlib.cmxa  --filter-recursive=Printf >hashes2
diff -u hashes1 hashes2

In fact such a tool could be built by parsing the output of ocamlobjinfo too:
ocamlobjinfo /usr/lib64/ocaml/stdlib.cmxa /path/to/4.02.2+rc1/stdlib.cmxa | ocamlobjdiff --module=Printf

Best regards,
--Edwin



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-26 21:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-23 19:52 [Caml-list] inconsistent assumptions over implementation Printf Richard W.M. Jones
2015-06-23 20:41 ` Török Edwin
2015-06-25  7:58   ` Richard W.M. Jones
2015-06-26 21:27     ` Török Edwin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).