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).
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.
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.