Conversation
Notices
-
Embed this notice
翠星石 (suiseiseki@freesoftwareextremist.com)'s status on Wednesday, 19-Mar-2025 22:30:42 JST 翠星石
@Revertron @rayslava What do you want it to do, cause a segfault?
You have the freedom to reference memory at random; `printf("Number: %d\n", *(int *)0xDEADBEEF);` (with a MMU this will segfault unless the program has such address mapped to it).-
Embed this notice
翠星石 (suiseiseki@freesoftwareextremist.com)'s status on Thursday, 20-Mar-2025 11:56:19 JST 翠星石
@divVerent @Revertron @rayslava GHC is at least free software (despite taking forever to compile), thus Haskell is acceptable.
>this is an unaligned address for int, and it's quite expected for this to still segfault
The target was AMD64 and that doesn't care about unaligned addressing - dereferencing a valid unaligned pointer will not segfault, it will just be slow.
It's a different matter for other arches like Aarch64, where unaligned addressing is not allowed.
>the compiler could already error, as it can know this is never a valid int pointer.
Yes, the compiler could deduce that 0xDXXXXXXX is above the bits assigned to memory addressing on all current machines, but clearly you know what you are doing (you want to read from a MSR or something), thus the compiler doesn't stop you from doing so. -
Embed this notice
divVerent (divverent@misskey.de)'s status on Thursday, 20-Mar-2025 11:56:21 JST divVerent
@Suiseiseki@freesoftwareextremist.com @Revertron@zhub.link @rayslava@lor.sh Bad example ;) this is an unaligned address for int, and it's quite expected for this to still segfault (or rather, bus error) even if the page at the address is mapped.
In fact, in this particular example, the compiler could already error, as it can know this is never a valid int pointer.
-
Embed this notice