Unicorn with delicious cookie
Nous utilisons des cookies pour améliorer votre expérience de navigation. En savoir plus
Accepter
to the top
>
>
Problems of 64-bit code in real program…

Problems of 64-bit code in real programs: FreeBSD

02 Fév 2009

While telling people about problems and difficulties of developing 64-bit applications I often hear in response: "You just should write programs well and there will be no problems". What only have we done trying to persuade people that this view is absurd! We wrote articles, gave examples but there still were those who would stick to their opinion.

Surfing recently through the net searching for discussions of problems relating to 64-bit, at some forum I came across a description of strange behavior of a program for reading files. This program couldn't read a file of more than 2 GB although the code was correct:

size_t size;
size = fread(...);

Investigation showed that the error was... inside fread function of FreeBSD!

It is difficult to believe in this that's why I will prove my words. You can see the code of fread function in the repository of FreeBSD source code http://svnweb.freebsd.org/:

size_t
fread(void * __restrict buf, size_t size,
        size_t count, FILE * __restrict fp)
{
  int ret;
  FLOCKFILE(fp);
  ret = __fread(buf, size, count, fp);
  FUNLOCKFILE(fp);
  return (ret);
}

Oh my God, how could one define ret variable as int? Of course it's absolutely incorrect. This error was corrected... only in December 2008:

size_t
fread(void * __restrict buf, size_t size,
        size_t count, FILE * __restrict fp)
{
  size_t ret;
  FLOCKFILE(fp);
  ret = __fread(buf, size, count, fp);
  FUNLOCKFILE(fp);
  return (ret);
}

It is astonishing that an error in FreeBSD was corrected only in the end of 2008. Perhaps 64-bit systems are not called-for yet?

Popular related articles

S'abonner

Comments (0)

close comment form
close form

Remplissez le formulaire ci‑dessous en 2 étapes simples :

Vos coordonnées :

Étape 1
Félicitations ! Voici votre code promo !

Type de licence souhaité :

Étape 2
Team license
Enterprise licence
** En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité
close form
Demandez des tarifs
Nouvelle licence
Renouvellement de licence
--Sélectionnez la devise--
USD
EUR
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
La licence PVS‑Studio gratuit pour les spécialistes Microsoft MVP
close form
Pour obtenir la licence de votre projet open source, s’il vous plait rempliez ce formulaire
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
I want to join the test
* En cliquant sur ce bouton, vous déclarez accepter notre politique de confidentialité

close form
check circle
Votre message a été envoyé.

Nous vous répondrons à


Si l'e-mail n'apparaît pas dans votre boîte de réception, recherchez-le dans l'un des dossiers suivants:

  • Promotion
  • Notifications
  • Spam