#27 Obsolete use of smsw instructions in MMX.cpp


libdjvulibre-3.5.22 sometimes failed in evince 2.30.3 on large documents (more than 10Mb). Valgrind shows that was when libdjvulibre tries to run uknown instruction "smsw" in MMX.cpp. Intel manual on x86 (vol. 2) shows that this instruction is obsolete and should be replaced by "mov ???, cr0" on i386 and higher. I tried to change it in 3.5.22 and evince stopped failing indeed.

My patch is for version libdjvulibre-3.5.24 and replaces "smsw" by "mov" in MMX.cpp (since I assume it may still fail sometimes).


  • Leon Bottou

    Leon Bottou - 2011-12-28

    Thanks for your analysis.

    Unfortunately this cannot be the cause of the problems you describe.
    The code you change is the canonical code (from intel) to detect whether a x86 processor
    supports MMX. This is executed only once at the beginning and is not dependent on the
    size of the djvu document. The fact that valgrind does not know this rare instruction
    does not mean much. Also the mov cr0 instruction has the disadvantage of revealing
    the privileged part of cr0, and that can cause issues in virtual machines.

    Question: does the bug occur while running linux in a virtual machine?

    - L.

  • Leon Bottou

    Leon Bottou - 2011-12-28

    P.S. --
    I do not mean that I reject the patch, but that I need more information to be sure not to make a mistake.

  • Leon Bottou

    Leon Bottou - 2014-10-28
    • status: open --> closed
    • Group: --> Unstable_(example)

Log in to post a comment.