Skip to content

division by zero in ide

Host environment

  • Operating system: Ubuntu 22.04.4 LTS
  • OS/kernel version: Linux 6.5.0-25-generic
  • Architecture: x86_64
  • QEMU flavor: 9.0.0
  • QEMU version: commit b23acd3e

Description of problem

The following log reveals it:

../hw/ide/core.c:659:26: runtime error: division by zero
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../hw/ide/core.c:659:26 in AddressSanitizer:DEADLYSIGNAL ================================================================= 
==4104568==ERROR:AddressSanitizer:FPE on unknown address 0x559d996a7ec3 (pc 0x559d996a7ec3 bp 0x7ffdcf109da0 sp 0x7ffdcf109a40 T0) 
#0 0x559d996a7ec3 in ide_set_sector qemu/hw/ide/core.c:659:26 
#1 0x559d996c8dee in ide_sector_read_cb qemu/hw/ide/core.c:786:5 
#2 0x559d996aa50a in ide_buffered_readv_cb qemu/hw/ide/core.c:684:9 
#3 0x559d9b499289 in blk_aio_complete qemu/block/block-backend.c:1555:9 
#4 0x559d9b4891af in blk_aio_complete_bh qemu/block/block-backend.c:1565:5 
#5 0x559d9bbef6b1 in aio_bh_call qemu/util/async.c:171:5 
#6 0x559d9bbf058c in aio_bh_poll qemu/util/async.c:218:13 
#7 0x559d9bb58a28 in aio_dispatch qemu/util/aio-posix.c:423:5 
#8 0x559d9bbf69ce in aio_ctx_dispatch qemu/util/async.c:360:5 
#9 0x7f51fbc77d3a in g_main_context_dispatch (/lib/x86_64-linux-gnu/libglib-2.0.so.0) +0x55d3a.+0x55d3a) 
#10 0x559d9bbfa229 in glib_pollfds_poll qemu/util/main-loop.c:287:9 
#11 0x559d9bbf8b63 in os_host_main_loop_wait qemu/util/main-loop.c:310:5 
#12 0x559d9bbf872c in main_loop_wait qemu/util/main-loop.c:589:11 
#13 0x559d9a2640e7 in qemu_main_loop qemu/system/runstate.c:796:9 
#14 0x559d9b1dcaec in qemu_default_main qemu/system/main.c:37:14 
#15 0x559d9b1dcb37 in main qemu/system/main.c:48:12 
#16 0x7f51fb229d8f in __libc_start_call_main csu/.../sysdeps/nptl/libc_start_call_main.h:58:16 
#17 0x7f51fb229e3f in __libc_start_main csu/../csu/libc-start.c:392:3 #18 0x559d98f20ed4 in _start (/home/joey/repo/qemu/build/qemu-system-x86_64+0x1f93ed4)

Reproducer

cat << EOF | qemu-system-x86_64 -display none \
-machine accel=qtest, -m 512M -machine pc -nodefaults -drive \
file=null-co://,if=none,format=raw,id=disk0 -device ide-hd,drive=disk0 \
-qtest stdio
outl 0xcf8 0x80000920
outl 0xcfc 0xc000
outl 0xcf8 0x80000904
outw 0xcfc 0x05
outb 0x177 0xf5
outb 0x177 0x91
outb 0xc008 0x1
outb 0x177 0x20
EOF
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information