tmp1 = (simtime - seg->time) / currdisk->rotatetime;
currdisk->currangle += tmp1;
The above code can also cause NaN in the later calling.
So I step into to the assembly.
tmp1 = (simtime - seg->time) / currdisk->rotatetime;
0x0808fdf4 <disk_buffer_sector_done+559>: fldl 0x80b2208
0x0808fdfa <disk_buffer_sector_done+565>: mov -0x38(%ebp),%eax
0x0808fdfd <disk_buffer_sector_done+568>: fldl (%eax)
...Here, the content of %eax is 0x80bdfeb, which is the address of seg->time.
After the above "fldl (%eax) " executed, the content of register st0 is 0x8000000000000000, which represents NaN.
So the NaN is propagated to the following instructions. This is the key issue.
0x0808fdff <disk_buffer_sector_done+570>: fsubrp %st,%st(1)
0x0808fe01 <disk_buffer_sector_done+572>: mov 0x8(%ebp),%eax
0x0808fe04 <disk_buffer_sector_done+575>: fldl 0xc4(%eax)
0x0808fe0a <disk_buffer_sector_done+581>: fdivrp %st,%st(1)
0x0808fe0c <disk_buffer_sector_done+583>: fstpl -0x28(%ebp)