Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCaml 3.01 does not compile on FreeBSD 2.2.5 #2706

Closed
vicuna opened this issue Mar 14, 2001 · 3 comments
Closed

OCaml 3.01 does not compile on FreeBSD 2.2.5 #2706

vicuna opened this issue Mar 14, 2001 · 3 comments
Labels

Comments

@vicuna
Copy link

vicuna commented Mar 14, 2001

Original bug ID: 309
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)

Bug description

Full_Name: Jacques Garrigue
Version: 3.01
OS: FreeBSD 2.2.5
Submission from: orion.kurims.kyoto-u.ac.jp (130.54.16.5)
Submitted by: garrigue

La compilation echoue dans make world, a` la premiere tentative de compilation
de pervasives.mli.

Le probleme semble etre present sur toute la branche 2.2 de FreeBSD (avant le
passage a ELF). 3.00 compile sans probleme. (Ca ne doit pas toucher grand monde, et la machine en question devrait passer a FreeBSD 4.2 prochainement.)

Ca semble etre lie au passage de certaines valeurs en flottant.
Voici une trace.

cascade-stdlib> gdb ../byterun/ocamlrund
GDB is free software and you are welcome to distribute copies of it
under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for details.
GDB 4.16 (i386-unknown-freebsd),
Copyright 1996 Free Software Foundation, Inc...
(gdb) run ../boot/ocamlc -g -nopervasives -c pervasives.mli
Starting program: /tmp/ocaml-3.01/stdlib/../byterun/ocamlrund ../boot/ocamlc -g
-nopervasives -c pervasives.mli

O'Caml runtime: debug mode

Initial minor heap size: 128k bytes
Initial major heap size: 248k bytes
Initial space overhead: 42%
Initial max overhead: 1000000%
Initial heap increment: 248k bytes
Initial stack limit: 1024k bytes
Starting new major GC cycle

O'Caml runtime: heap check

!
Program received signal SIGFPE, Arithmetic exception.
0x60e5 in float_of_bytes (s=438716) at floats.c:313
313 return copy_double(u.d);
(gdb) back
#0 0x60e5 in float_of_bytes (s=438716) at floats.c:313
#1 0x14951 in interprete (prog=0x93000, prog_size=651380) at interp.c:830
#2 0x165b3 in caml_main (argv=0xefbfda68) at startup.c:382
#3 0x2137 in main (argc=6, argv=0xefbfda68) at main.c:41
(gdb) print u.d
$1 = NaN(0x1)

@vicuna
Copy link
Author

vicuna commented Mar 14, 2001

Comment author: administrator

Apres analyse plus detaillee, il semble que ce soit du a un comportement
bizarre des flottants en FreeBSD avant la version 3.1.

Heureusement, Xavier a tout prevu, et il suffit d'ajouter l'initialisation
necessaire dans init_ieee_floats. Le plus interessant est que ca n'avait jamais
pose' de probleme jusqu'a` present.

Voici un patch pour les non-CVSers.

Index: byterun/floats.c

RCS file: /net/pauillac/caml/repository/csl/byterun/floats.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -c -r1.25 -r1.26
*** floats.c 2001/02/05 08:51:16 1.25
--- floats.c 2001/03/14 05:36:59 1.26


*** 362,367 ****
--- 362,377 ----
of signalling exceptions. Currently, everyone is in IEEE mode
at program startup. */

  • #ifdef FreeBSD
  • #include <osreldate.h>
  • #if (__FreeBSD_version < 310000)
  • #include <floatingpoint.h>
  • #endif
  • #endif
  • void init_ieee_floats(void)
    {
  • #if defined(FreeBSD) && (__FreeBSD_version < 310000)
  • fpsetmask(fpgetmask() & ~(FP_X_DZ | FP_X_INV));
  • #endif
    }

@vicuna
Copy link
Author

vicuna commented Mar 14, 2001

Comment author: administrator

FreeBSD specific problem. Fixed by JG on 2001-03-14.

@vicuna vicuna closed this as completed Mar 14, 2001
@vicuna
Copy link
Author

vicuna commented Mar 15, 2001

Comment author: administrator

Le probleme semble etre present sur toute la branche 2.2 de FreeBSD (avant le
passage a ELF). 3.00 compile sans probleme. (Ca ne doit pas toucher grand monde, et la machine en question devrait passer a FreeBSD 4.2 prochainement.)

Ca semble etre lie au passage de certaines valeurs en flottant.
Voici une trace.

Je conjecture / crois me souvenir que les versions anciennes de FreeBSD
mettaient le processeur flottant en mode "trapping" au lieu du mode "IEEE".
Ceci produit un signal SIGFPE dès que des valeurs flottantes inhabituelles
(Nan, infinity) sont manipulées. Dans 3.01, j'ai justement rajouté
des choses (Pervasives.nan) qui provoquent la manipulation de telles
valeurs lors de l'initialisation du module Pervasives...

Comme tu le dis, les versions plus récentes de FreeBSD (en fait, tous
les OS modernes) sont en mode IEEE. Cependant, je pourrais et vais
réécrire float_of_bytes pour que ça ne plante pas sur des
architectures non IEEE.

  • Xavier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant