Matteo Concas created a merge request: https://gitlab.rtems.org/rtems/pkg/rtems-libbsd/-/merge_requests/171
Project:Branches: matteo.concas/gaisler-lib-bsd:matteo/up/mdns-fix to rtems/pkg/rtems-libbsd:7-freebsd-14 Author: Matteo Concas ## Summary mDNS: Add `-fwrapv` flag mDNSCore schedules with wrapping `int32_t` tick arithmetic (e.g. `timenow + FutureTime`, `a - b < 0`) and is built with `-fwrapv` upstream (`mDNSPosix/Makefile`). Without it, GCC folds the comparisons and the scheduler breaks whenever the randomly offset `timenow` is within `FutureTime` of `INT32_MAX`. <details> <summary>Agent explanation of the bug</summary> Cause: - Clock offset: mDNSCore keeps time as timenow, a 32-bit tick count (1024 per second) plus a random offset chosen at each boot. - "Nothing scheduled" marker: it marks "nothing scheduled" as timenow + FutureTime, where FutureTime is 0x38000000, and relies on that sum wrapping around when it overflows. - Upstream flag: upstream compiles mDNSResponder with -fwrapv for that reason (mDNSPosix/Makefile:65). - libbsd: libbsd doesn't use that flag. Without it, signed overflow is undefined in C, and GCC turned checks like timenow - NextScheduledResponse >= 0 into a plain timenow >= NextScheduledResponse. I confirmed this in the disassembly at mDNS.c:5600, 5601 and 912. - Effect: once timenow passes INT32_MAX − FutureTime (1,207,959,551), the marker becomes negative and every check reads it as overdue: - The response check fires on every pass, which gives the stream of "SendResponses didn't send all its responses". - A clamp resets the next probe time to timenow, which gives "didn't send all its probes (X − X = 0)". </details> ## AI Details <!-- Make sure you have read our statement at https://www.rtems.org/generative-ai/ --> ### Prompt used <!-- Prompt used, please write ‘None’ if no prompt was used --> ### AI model used <!-- Please list AI models you have used --> Opus 5.5 with Fable 5.2 as an advisor ### How AI was used for the contribution While chasing another bug and with mDNS enabled sometimes the RTEMS application would output `mDNS_Execute: SendResponses didn't send all its responses` to console continuously, I had the AI track down this other bug and suggest a fix. If others were used please add below ### Access <!-- Please state that you have not used a product that claims copyright and you have legitimate access. --> <!-- Default settings, if it is a dropdown it will set after submission --> -- View it on GitLab: https://gitlab.rtems.org/rtems/pkg/rtems-libbsd/-/merge_requests/171 You're receiving this email because of your account on gitlab.rtems.org. Unsubscribe from this thread: https://gitlab.rtems.org/-/namespace/20/sent_notifications/6-d8hpn61yppf8jdhu00rltwxrb-k/unsubscribe | Manage all notifications: https://gitlab.rtems.org/-/profile/notifications | Help: https://gitlab.rtems.org/help
_______________________________________________ bugs mailing list [email protected] http://lists.rtems.org/mailman/listinfo/bugs
