Re: [hatari-devel] undefined behaviour fixes |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- To: hatari-devel@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [hatari-devel] undefined behaviour fixes
- From: Andreas Grabher <andreas_g86@xxxxxxxxxx>
- Date: Mon, 6 Jan 2025 11:12:55 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1736158406; bh=kHweT2PzoVAIJS8s+HG7+6ua+UPCIStf8F7U0KnKk2c=; h=From:Content-Type:Mime-Version:Subject:Date:To:Message-Id: x-icloud-hme; b=cD5TEQF1+jz1gVWm+kLOZICv2wnipBCyBkK4BlW9sq+RjQWibJUz9MDCGUcAWJXDl tppyr1Usb/IIBuBveamnT7ovr7aNoP0DNXSbVAbFI0d4D7FQj0jJX5/M1ch2Ol5Dvc QjU4imL1n23tr8WrepdWJEigy+rmv8+tf0n+uUW00XnxPmXdDomjp4g1NTacSkLv+I 5SBAW8uRpgR3xW2Xz01ugUdKfNVx5rtvlT9UBSfEE9lQpIB7XschaA3bVZ0cgUtcRu xk21XmL3OSTPF6yP4qa33hzlUWxg6idXYtzCRaKl+phI/A7ftolqnWOKNNbKYAjKHn OQqXLHQZNLAkQ==
> Am 06.01.2025 um 10:45 schrieb Nicolas Pomarède <npomarede@xxxxxxxxxxxx>:
>
> Le 06/01/2025 à 10:39, Andreas Grabher a écrit :
>>> Am 05.01.2025 um 12:39 schrieb Andreas Grabher <andreas_g86@xxxxxxxxxx>:
>>>
>>>
>>>> Am 04.01.2025 um 18:07 schrieb Andreas Grabher <andreas_g86@xxxxxxxxxx>:
>>>>
>>>>
>>>>> Am 31.12.2024 um 18:24 schrieb Andreas Grabher <andreas_g86@xxxxxxxxxx>:
>>>>>
>>>>> Hello Toni,
>>>>>
>>>>> here is a little patch that should fix some undefined behaviour (getting these from runtime checking). Please review before applying the patch.
>>>>>
>>>>> There are many more warnings from cpuemu_XX files. But I don’t know how to fix those.
>>>>>
>>>>> Kind regards,
>>>>> Andreas
>>>>>
>>>>> <cpu_warnings.txt>
>>>>
>>>> I found some more. An updated patch is appended.
>>>>
>>>> <cpu_warnings2.txt>
>>>
>>> Another patch is appended. Now I also fixed the problems in the cpuemu_XX files. Please note that I only use cpuemu_31 and cpuemu32, so others are untested. It seems that all is working normally. But anyway I think some heavy review is needed, especially for the changes in gencpu.
>>>
>>> I really think these issues need to be fixed, because with the current code undefined behaviour can occur in many critical functions.
>>>
>>> Good news for Hatari: Although I tested only with Previous, no undefined behaviour was not detected in any file that was derived from Hatari, including all DSP code.
>>>
>>> <cpu_warnings3.txt>
>> I’ve run into problems with my last patch. So here is a new one. There is quite some type chaos inside the CPU code. I get lots of undefined signed integer overflow, shifting with values greater than type size, shifting negative values, shifting with negative shifts, etc. Not sure this fixes all of them, but at least I no longer run into one of these immediately.
>
> Hi
>
> I'll let Toni comment on this (now that he committed his new chipset emulation for WinUAE 6.x he might have more time to look into this :) )
>
> but just for the information, what compiler / flags are you using ? I'm using the very latest GCC and never saw these warnings. I don't see them either on our cirrus-ci jobs.
>
> Nicolas
>
I am not very used to debugging. I am using the latest version of Xcode with Runtime Undefined Behavior Sanitizer activated.
The problem is of course that the errors are only detected when a faulty function is called with a corresponding input value. So there might be more such problems hidden in the code.