Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UB in certain scenarios #6021

Open
cawtds opened this issue Jan 13, 2025 · 0 comments
Open

UB in certain scenarios #6021

cawtds opened this issue Jan 13, 2025 · 0 comments
Labels
bug Bug category: battle-mechanic Pertains to battle mechanics status: unconfirmed This bug has not been reproduced yet

Comments

@cawtds
Copy link

cawtds commented Jan 13, 2025

Description

After some testing it seems to only cause issue, when the opposing mon use non-selfcast moves. Tested by giving every opposing mon only one move,
Tackle, Tail Whip, Thunder Shock -> UB
Nasty Plot, Harden -> no UB?
First commit with this behaviour seem to be 97b30cb

Setup:

  • FRLG asserts in FreeInternal;
+#define ABSPATH(x) (x)
...
void FreeInternal(void *heapStart, void *pointer)
{
    if (pointer)
    {
        struct MemBlock *head = (struct MemBlock *)heapStart;
        struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock));
+       AGB_ASSERT_EX(block->magic == MALLOC_SYSTEM_ID, ABSPATH("gflib/malloc.c"), 204);
...
        if (block != head)
        {
            if (!block->prev->allocated)
            {
+               AGB_ASSERT_EX(block->prev->magic == MALLOC_SYSTEM_ID, ABSPATH("gflib/malloc.c"), 228);
...
  • Lvl 15 Bulbasaur, with Tackle, Growl, Razor Leaf, Leech Seed
  • edit trainer party to the following, e.g.:
=== TRAINER_HALEY_1 ===
Name: GREG
Class: Bug Catcher
Pic: Bug Catcher
Gender: Male
Music: Male
Double Battle: No
AI: Check Bad Move

Weedle
Level: 9
IVs: 0 HP / 0 Atk / 0 Def / 0 SpA / 0 SpD / 0 Spe

Kakuna
Level: 9
IVs: 0 HP / 0 Atk / 0 Def / 0 SpA / 0 SpD / 0 Spe

Caterpie
Level: 9
IVs: 0 HP / 0 Atk / 0 Def / 0 SpA / 0 SpD / 0 Spe

Metapod
Level: 9
IVs: 0 HP / 0 Atk / 0 Def / 0 SpA / 0 SpD / 0 Spe

Execution:

  • spam Tackle until the battle is won

Result:
ub

without asserts:
image

Version

upcoming (Edge)

Upcoming/master Version

ce40c33

Discord contact info

.cawt

@cawtds cawtds added bug Bug category: battle-mechanic Pertains to battle mechanics status: unconfirmed This bug has not been reproduced yet labels Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug category: battle-mechanic Pertains to battle mechanics status: unconfirmed This bug has not been reproduced yet
Projects
None yet
Development

No branches or pull requests

1 participant