#602170 [libbz2-ocaml] exceptions don't get registered properly

Package:
libbz2-ocaml
Source:
camlbz2
Description:
OCaml bindings for the bzip2 compression library (runtime)
Submitter:
Joost Yervante Damad
Date:
2010-11-04 09:03:08 UTC
Severity:
important
#602170#5
Date:
2010-11-02 08:28:28 UTC
From:
To:
--- Please enter the report below this line. ---

whenever there's something wrong, the binding looks up the exception to be
thrown, and throws it.
The exceptions are supposed to be registered in the Bz2 module with
let _ = begin
  ...
  Callback.register_exception "mlbz_data_exn" Data_error;
  ...
end

unfortunately this does not happen.
(you can add a print statement to see for yourself that it does not get
executed in a program)

more details, including a patch with a possible solution can be found at:

https://forge.ocamlcore.org/tracker/index.php?func=detail&aid=768&group_id=63&atid=338

As upstream seems quite unresponsive maybe this simple fix can be integrated in
Debian directly.

greetings, Joost Damad

Debian Release: squeeze/sid
  500 unstable        www.debian-multimedia.org
  500 unstable        ftp.nl.debian.org
  500 testing         dl.google.com
--- Package information. ---
Depends                    (Version) | Installed
====================================-+-===========
ocaml-base-nox-3.11.2                |
libbz2-1.0                           | 1.0.5-6
libc6                     (>= 2.2.5) | 2.11.2-6


Package's Recommends field is empty.

Package's Suggests field is empty.

#602170#14
Date:
2010-11-02 09:45:37 UTC
From:
To:
tags 602170 + confirmed
severity 602170 important
thanks

Le 02/11/2010 09:28, Joost Yervante Damad a écrit :

If you add "let _ = Bz2.version;;" at the beginning of your segfaulting
example, it doesn't segfault any more.

The reason why exceptions are not registered is because the Bz2 module
is not linked in, and therefore its side-effects are not executed. This
is because your example uses only externals that are declared as such in
bz2.mli. This is unfortunate, but a known issue.

I don't agree with you patch. The right fix IMHO would be to make one
(or all) of the externals abstract in the .mli file. This would
theoretically impact performances in bytecode, but I think not in native
code because of inlining. But if performances are critical even in
bytecode, I'd rather name the proposed function "init" instead of
"register_exceptions" which doesn't look very elegant... Any other
opinion on this would be welcome.

Anyway, this would be an intrusive change (ABI change in interface ->
binNMU of all reverse-dependencies), the problem is known and can be
worked around, and we are in freeze, so I'd rather fix it later, after
Squeeze release. Therefore, I hereby downgrade the severity to important.


Cheers,

#602170#23
Date:
2010-11-02 10:05:34 UTC
From:
To:
Hi Stéphane,

thanks for the quick feedback and providing a nice workaround. In the light of
that I fully support the priority change.

thanks, Joost

On Tuesday 02 November 2010 10:45:37 Stéphane Glondu wrote:
[snip]

#602170#28
Date:
2010-11-03 11:36:23 UTC
From:
To:
Stéphane Glondu <glondu@debian.org> writes:

Please do fix this though. Make some/all externals abstract to force
linking in the module. Some speed penalty is preferable to
segfaults. Hoping users will call Bz2.version is just not going to work.

MfG
        Goswin