Class fields overlapping?

About Monkey 2 Forums Monkey 2 Programming Help Class fields overlapping?

This topic contains 3 replies, has 2 voices, and was last updated by  Mark Sibly 2 years, 11 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1933

    sicilica
    Participant

    So I have a superclass I use to represent the object hierarchy in a scene:

    It works beautifully, but if I add ANY other fields to the class that aren’t primitive types (ie, Ints and stuff), then there are all sorts of runtime memory access problems. For example, simply adding “Field obj:Object” with the other private fields causes the DebugAssert in AddChild() to fail – and if you look at the debugger for the child object in question, it’s not hard to see why.

    The field added by the subclass, collisionMask, somehow has the same pointer as parent does, even though they are completely disparate types – and while the subclass constructor assigned to collisionMask, nothing has assigned to parent. In fact, short of adding the additional field to the superclass, I changed nothing in the codebase from when it ran totally fine.

    I haven’t been able to replicate this in a controlled environment, so it could be affected by something else in my project? I can provide any outputs that would help. It definitely seems like something about how the class is being compiled is broken.

    #1994

    Mark Sibly
    Keymaster

    Any chance you can send me the project? Try and get it as ‘small’ as possible first please!

    I doubt the fields are ‘overlapping’, but there’s a chance debugger output could be incorrect so that could be confusing things.

    It could also be a GC issue. You could try enabling the #define BBGC_DEBUG 1 in modules/monkey/native/bbgc.h and rebuilding everything. This will cause the app to leak ALL memory allocated (so the bug better happen fast!) but it will bring up an error if a chunk of memory is incorrectly re-used.

    #2106

    sicilica
    Participant

    In case anyone has this problem in the future, deleting your build folder and rebuilding works, and hopefully it won’t be long until a fix is live. Thanks Mark!

    #2145

    Mark Sibly
    Keymaster

    This turned out ot be a ‘spaces in filename’ build issue, but was kind of fun to find.

    The main problem was that mx2cc wasn’t recognizing a file had changed so wasn’t rebuilding it.

    But each time I tried to add something to the monkey module to do some testing, this was enough to trigger a rebuild! So I ended up having to add a new foobar field after each modules update – I ended up with about 5 foobars before it clicked what was happening…

    For a while it seemed like the ultimate heisenbug – each time I tried to measure it, it very predictably disappeared!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.