• AVR Freaks

Hot!Pointer to complex Struct with Array in XC32 sometimes causing runtime crashes

Author
Paul PortSol
Super Member
  • Total Posts : 484
  • Reward points : 0
  • Joined: 2015/07/03 11:52:03
  • Location: Newfoundland, Canada
  • Status: offline
2019/04/11 06:09:14 (permalink)
0

Pointer to complex Struct with Array in XC32 sometimes causing runtime crashes

Just wondering if I'm alone in seeing this weird bug.
 
I've had it happen several times, and have "wiggled" the code to get past it.
I pass a pointer to complex struct, and depending on the surrounding code I get runtime crashes.
I tweek the code around the problem line (I don't change the problem line) and the crash goes away.
Usually the issue is with a line that is simply a diagnostic printf displaying a few elements of the pointed to struct, but sometimes it is some math or other code.
 
The only common part seems to be: Pointer to struct, struct contains an array.
 
I haven't managed to reproduce this in a simple test program, thus can't submit a ticket yet.
 
 
I'm using MPLABXv515, XC32v215, HarmonyV206, PIC32MX370F512H,
but I've had same issues in past with PIC32MZ, and earlier versions of MPLABXv4xx, XC32v2xx, HarmonyV2xx
 
Paul
 
#1

7 Replies Related Threads

    NKurzman
    A Guy on the Net
    • Total Posts : 17720
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Pointer to complex Struct with Array in XC32 sometimes causing runtime crashes 2019/04/11 06:22:26 (permalink)
    +1 (1)
    Crash means what? Are you getting an exception? If you are copying a struct to a RAM buffer then using a pointer on it, is it properly aligned?
    #2
    Paul PortSol
    Super Member
    • Total Posts : 484
    • Reward points : 0
    • Joined: 2015/07/03 11:52:03
    • Location: Newfoundland, Canada
    • Status: offline
    Re: Pointer to complex Struct with Array in XC32 sometimes causing runtime crashes 2019/04/11 06:27:12 (permalink)
    0
    Crash = PIC Resets
    Isn't doesn't give an exception.
     
    All the memory is OK, as it works when I change surrounding code (not change resetting line).
    Also sometimes works if Split an offending printf into two chunks, with no changes to format or objects.
     
    (I have had pointer issues and recognize the difference, which is what makes this so frustrating. It really seems to be an XC32 bug with pointers to complex structs).
     
     
    #3
    NorthGuy
    Super Member
    • Total Posts : 5585
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: Pointer to complex Struct with Array in XC32 sometimes causing runtime crashes 2019/04/11 07:03:12 (permalink)
    +2 (2)
    Paul PortSol
    I pass a pointer to complex struct, and depending on the surrounding code I get runtime crashes.
    I tweek the code around the problem line (I don't change the problem line) and the crash goes away.



    This is very typical. You have some sort of unutialized (or incorrectly initialzed) pointer somewhere, which contains more or less random values. Sometimes, the random value which gets into the pointer is Ok, other times it causes crashes.
    #4
    NKurzman
    A Guy on the Net
    • Total Posts : 17720
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Pointer to complex Struct with Array in XC32 sometimes causing runtime crashes 2019/04/11 08:30:52 (permalink)
    +2 (2)
    Resets without an exception?
    All of the exceptions are handled?
    Check RCON and see if there is reason.  BOR? WDT?
    #5
    moser
    Super Member
    • Total Posts : 504
    • Reward points : 0
    • Joined: 2015/06/16 02:53:47
    • Location: Germany
    • Status: offline
    Re: Pointer to complex Struct with Array in XC32 sometimes causing runtime crashes 2019/04/11 09:36:22 (permalink)
    +1 (1)
    No exception? Are you checking all off those:
    _general_exception_handler()
    _simple_tlb_refill_exception_handler()
    _cache_err_exception_handler()
    _bootstrap_exception_handler()
    _DefaultInterrupt()
    Specifically _simple_tlb_refill_exception_handler() mostly happens for bad pointers. 
     
    And there is no Watchdog or Deadman timeout?  And as NKurzman said, what does RCON tell you?
    #6
    crosland
    Super Member
    • Total Posts : 1603
    • Reward points : 0
    • Joined: 2005/05/10 10:55:05
    • Location: Bucks, UK
    • Status: offline
    Re: Pointer to complex Struct with Array in XC32 sometimes causing runtime crashes 2019/04/11 10:23:02 (permalink)
    0
    You can get similar issues with data shared between main and ISRs not marked as volatile.
    #7
    Aussie Susan
    Super Member
    • Total Posts : 3612
    • Reward points : 0
    • Joined: 2008/08/18 22:20:40
    • Location: Melbourne, Australia
    • Status: offline
    Re: Pointer to complex Struct with Array in XC32 sometimes causing runtime crashes 2019/04/11 19:56:03 (permalink)
    +1 (1)
    Show us some code and then we might be able to help.
    AS others have said, the symptom of 'change something else where and it alters how a parameter is passed' is typical of several causes such as stack overflow, pointers misbehaving (pointing where they should not etc.) and misalignment between function calls and prototypes etc..
    Susan
    #8
    Jump to:
    © 2019 APG vNext Commercial Version 4.5