sim_irq: guard NULL pool in avr_irq_register_notify during reset - #584
sim_irq: guard NULL pool in avr_irq_register_notify during reset#584dmcgougan wants to merge 1 commit into
Conversation
Interrupt-vector IRQs are created with pool == NULL. avr_watchdog_reset() re-registers its notify hook from within avr_reset (while avr->resetting is set), so avr_irq_register_notify() dereferences irq->pool->avr->resetting on an IRQ whose pool is NULL and segfaults on any watchdog reset. Guard the NULL pool so the reset path is safe; the resetting-time value/flag reset simply does not apply to pool-less IRQs.
|
Please post code and instructions to reproduce the crash. |
|
Those IRQs are linked to the AVR pool like all the rest. This looks like raw LLM slop. |
|
You are right. Normal interrupt vectors belong to avr->irq_pool. The ATmega128 has no watchdog interrupt, so simavr declares it with _VECTOR(0), but avr_watchdog_reset() still registers an IRQ callback unconditionally. The generic null check is therefore wrong; the fix I should have submitted belongs in the simavr watchdog code: if (p->watchdog.vector) To reproduce, run ATmega128 code that triggers watchdog reset using this AVR sequence: wdt_enable(WDTO_15MS); It crashes simavr. Physical ATmega128 hardware resets normally. Submitted PR #587 to replace this one. |
Interrupt-vector IRQs are created with pool == NULL. avr_watchdog_reset() re-registers its notify hook from within avr_reset (while avr->resetting is set), so avr_irq_register_notify() dereferences irq->pool->avr->resetting on an IRQ whose pool is NULL and segfaults on any watchdog reset.
Guard the NULL pool so the reset path is safe; the resetting-time value/flag reset simply does not apply to pool-less IRQs.