Bochs: buffer overflow detected error while debugging bootloader

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
kushalv238
Posts: 2
Joined: Thu Apr 10, 2025 6:03 am

Bochs: buffer overflow detected error while debugging bootloader

Post by kushalv238 »

Hello, I am trying to get a hands-on on learning to create my os, but I am facing some issues trying to debug my bootloader. I had some problems with my bootloader, such as saving the wrong register on the stack, which caused my bootloader to crash. Then I tried Bochs to debug my code, but every time I try to run it, I get the error:

*** buffer overflow detected ***: terminated

This is what my config file looks like:

Code: Select all

megs: 128
romimage: file=/usr/share/bochs/BIOS-bochs-legacy, address=0xffff0000
vgaromimage: file=/usr/share/bochs/VGABIOS-lgpl-latest
floppya: 1_44=build/main_floppy.img, status=inserted
boot: floppy
mouse: enabled=0
display_library: sdl2
log: bochslog.txt
I fixed my bootloader issue, and now it loads on the qemu emulator as expected, but I still can't get Bochs to work.
I am on a windows os
Is there something wrong with my configuration? Is this a known issue with a specific Bochs version or SDL2 display? Or could it be because I'm using Windows WSL?
Any tips or suggestions would be greatly appreciated!

Thanks in advance!
User avatar
BenLunt
Member
Member
Posts: 962
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: Bochs: buffer overflow detected error while debugging bootloader

Post by BenLunt »

Is the "*** buffer overflow detected ***: terminated" error from Bochs or your boot loader? I am assuming from Bochs.

Your config file is missing a lot of items. Bochs will use defaults, of course, but it is best to specify your desires.

Code: Select all

config_interface: win32config
display_library: win32
cpu: model=p4_willamette, count=1, ips=50000000, reset_on_triple_fault=1, ignore_bad_msrs=1
cpu: cpuid_limit_winnt=0
#the MEGS: directive has been replaced with:
memory: guest=512, host=256, block_size=512
#I would use the lastest 32-bit BIOS instead of the Legacy BIOS.
romimage: file=......\BIOS-bochs-latest
#You can also try (from https://github.com/fysnet/i440fx)
#romimage: file=......\i440fx.bin
pci: enabled=1, chipset=i440fx
clock: sync=none, time0=local
#eventually you will want to use a hard drive or cdrom
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata0-master: type=disk, mode=flat, path="sample.img"
ata0-slave: type=cdrom, path="sample.iso", status=inserted
Have a look at https://github.com/bochs-emu/Bochs/blob ... s/.bochsrc for examples.

If you use the debugger interface, you can single step through your code and see the registers, memory, etc. as the code is being executed.

- Ben
stlw
Member
Member
Posts: 359
Joined: Fri Apr 04, 2008 6:43 am
Contact:

Re: Bochs: buffer overflow detected error while debugging bootloader

Post by stlw »

kushalv238 wrote: Thu Apr 10, 2025 6:21 am Hello, I am trying to get a hands-on on learning to create my os, but I am facing some issues trying to debug my bootloader. I had some problems with my bootloader, such as saving the wrong register on the stack, which caused my bootloader to crash. Then I tried Bochs to debug my code, but every time I try to run it, I get the error:

*** buffer overflow detected ***: terminated
Regardless of anything, Bochs should never end up with *** buffer overflow detected ***: terminated.
I suggest you to fill github ticket, of course after you try to most recent Bochs version.

Thanks,
Stanislav
User avatar
BenLunt
Member
Member
Posts: 962
Joined: Sat Nov 22, 2014 6:33 pm
Location: USA
Contact:

Re: Bochs: buffer overflow detected error while debugging bootloader

Post by BenLunt »

As Stanislav suggests, please go to https://github.com/bochs-emu/Bochs/issues and create a new issue. We already have your bochsrc.txt file, but please post your floppy image, as it was, so that we can reproduce the error. If you don't wish to signup for a github account, please post your floppy image somewhere else, and post the URL here.

On a side note, for those of you that don't know, Stanislav has written a lot of and maintains the CPU aspect of Bochs. With his work background, he is able to maintain the code to emulate very recent CPU aspects and instructions. A heartfelt thanks goes out to him for his work. Thanks Stanislav.
kushalv238
Posts: 2
Joined: Thu Apr 10, 2025 6:03 am

Re: Bochs: buffer overflow detected error while debugging bootloader

Post by kushalv238 »

BenLunt wrote: Sat Apr 12, 2025 11:00 am As Stanislav suggests, please go to https://github.com/bochs-emu/Bochs/issues and create a new issue. We already have your bochsrc.txt file, but please post your floppy image, as it was, so that we can reproduce the error. If you don't wish to signup for a github account, please post your floppy image somewhere else, and post the URL here.

On a side note, for those of you that don't know, Stanislav has written a lot of and maintains the CPU aspect of Bochs. With his work background, he is able to maintain the code to emulate very recent CPU aspects and instructions. A heartfelt thanks goes out to him for his work. Thanks Stanislav.
First of all, thanks for the reply.
Secondly, the error appears to stem from Bochs itself, and I am running Bochs on its latest version (3.0).

I attempted running it with the configuration file you provided, but unfortunately, I encountered the same issue.

For reference, my bootloader code and floppy image setup can be found on github: https://github.com/kushalv238/baremetal ... r/boot.asm

For the buffer overflow error, as suggested by Stanislav, I created an issue on the Bochs github.com here: https://github.com/bochs-emu/Bochs/issues/522

Any further suggestions or ideas would be greatly appreciated. Thank you again!
stlw
Member
Member
Posts: 359
Joined: Fri Apr 04, 2008 6:43 am
Contact:

Re: Bochs: buffer overflow detected error while debugging bootloader

Post by stlw »

As it looks like your problem is SDL2 specific you can try using another display library for now.
Post Reply