Skip to content

ESP32-C3: Rotary Encoder Usermod causes panic (Load access fault) when activated #5201

Closed

Description

@lnx1-1

What happened?

When activating the Rotary Encoder usermod on ESP32-C3 (SuperMini), the device immediately crashes with a "Load access fault" (Guru Meditation Error) and enters a boot loop.
The crash occurs even when:

No hardware is connected
All GPIO pins in the usermod config are set to "unused"
Simply enabling the usermod in the web interface triggers the crash

To Reproduce Bug

Hardware: ESP32-C3 SuperMini
WLED Version: 0.15.0-b3
Build Method: Web-based compiler (https://wled-install.github.io/)
Selected Build: ESP32-C3 (4MB Flash, M: Audioreactive, Usermods incl: Temp, AutoSave, 4-L Display, Rotary encoder)
Steps:

Flash WLED build with Rotary Encoder usermod to ESP32-C3
Complete initial setup (WiFi, etc.)
Navigate to Config → LED Preferences → Usermod settings
Set all Rotary Encoder pins to "unused"
Enable the Rotary Encoder usermod
Device immediately crashes and reboots

Expected Behavior

The usermod should initialize without crashing, even with all pins set to unused.
Serial Output

Install Method

Self-Compiled

What version of WLED?

WLED Version: 0.15.0-b3

Which microcontroller/board are you seeing the problem on?

ESP32-C3

Relevant log/trace output

[01:55:06]Guru Meditation Error: Core  0 panic'ed (Load access fault). Exception was unhandled.
[01:55:06]
[01:55:06]Core  0 register dump:
[01:55:06]MEPC    : 0x4206662a  RA      : 0x42066880  SP      : 0x3fca4d50  GP      : 0x3fc8d000  
[01:55:06]TP      : 0x3fc7c834  T0      : 0x42066628  T1      : 0x40389620  T2      : 0xffffffff  
[01:55:06]S0/FP   : 0x00000000  S1      : 0x00000000  A0      : 0x00000000  A1      : 0x00000000  
[01:55:06]A2      : 0x00000000  A3      : 0x000040d2  A4      : 0x000040d2  A5      : 0x25000000  
[01:55:06]A6      : 0xfa000000  A7      : 0x00000003  S2      : 0x3fc9d880  S3      : 0x00000000  
[01:55:06]S4      : 0x00000000  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000  
[01:55:06]S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
[01:55:06]T3      : 0x00000006  T4      : 0x00000000  T5      : 0x00000030  T6      : 0x00000000  
[01:55:06]MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000005  MTVAL   : 0x00000010  
[01:55:06]MHARTID : 0x00000000  
[01:55:06]
[01:55:06]Rebooting...

Anything else?

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. coderabbitai commented on Dec 17, 2025

    @coderabbitai
    Contributor

    📝 CodeRabbit Plan Mode

    Generate an implementation plan and prompts that you can use with your favorite coding agent.

    • Create Plan
    Examples
    You can configure auto-planning by selecting labels in the issue_enrichment configuration.

    🔗 Similar Issues

    Related Issues

    👤 Suggested Assignees


    🧪 Issue enrichment is currently in open beta.

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false

    💬 Have feedback or questions? Drop into our discord or schedule a call!

  2. added
    confirmed
    on Dec 17, 2025
  3. DedeHai commented on Dec 17, 2025

    @DedeHai
    Collaborator

    I looked at this before, IIRC the workaround was to add a custom palette before enabling it.

  4. DedeHai commented on Dec 17, 2025

    @DedeHai
    Collaborator

    It's an off-by-one error, overrunning an array. I will check if I can fix it.

  5. lnx1-1 commented on Dec 17, 2025

    @lnx1-1
    Author

    I looked at this before, IIRC the workaround was to add a custom palette before enabling it.

    I tried to set a custom color palette. But it just crashed again when I enabled the mod:

    [13:28:54]
    [13:28:54]Core  0 register dump:
    [13:28:54]MEPC    : 0x4206662a  RA      : 0x42066880  SP      : 0x3fca4d50  GP      : 0x3fc8d000  
    [13:28:54]TP      : 0x3fc7c834  T0      : 0x42066628  T1      : 0x40389620  T2      : 0xffffffff  
    [13:28:54]S0/FP   : 0x00000000  S1      : 0x00000000  A0      : 0x00000000  A1      : 0x00000000  
    [13:28:54]A2      : 0x00000000  A3      : 0x00005647  A4      : 0x00005647  A5      : 0x92800000  
    [13:28:54]A6      : 0xfa000000  A7      : 0x00000003  S2      : 0x3fc9d880  S3      : 0x00000000  
    [13:28:54]S4      : 0x00000000  S5      : 0x00000000  S6      : 0x00000000  S7      : 0x00000000  
    [13:28:54]S8      : 0x00000000  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
    [13:28:54]T3      : 0x00000006  T4      : 0x00000000  T5      : 0x00000030  T6      : 0x00000000  
    [13:28:54]MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000005  MTVAL   : 0x00000010  
    [13:28:54]MHARTID : 0x00000000  
    [13:28:54]
    [13:28:54]Stack memory:
    [13:28:54]3fca4d50: 0x3fc9d880 0x00005647 0x00000000 0x42066880 0x3fc9d880 0x3fc9e000 0x3fc8f650 0x4200133c
    [13:28:54]3fca4d70: 0x3fc9d880 0x3c12872c 0x3c12872c 0x42048232 0x3fc9d880 0x3fc9e000 0x42068cde 0x4204b29c
    [13:28:54]3fca4d90: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x3fc9e000 0x42068cde 0x4204b5be
    [13:28:54]3fca4db0: 0x00000000 0x3fc9e000 0x42068cde 0x4206cb40 0x00000000 0x00000000 0x00000000 0x40387e9a
    [13:28:54]3fca4dd0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
    [13:28:54]3fca4df0: 0xa5a5a5a5 0xa5a5a5a5 0x00000154 0x3fca4b60 0x00005128 0x3fc9a0ac 0x3fc9a0ac 0x3fca4dfc
    [13:28:54]3fca4e10: 0x3fc9a0a4 0x00000018 0xef20ee42 0xea6e9f65 0x3fca4dfc 0x00000000 0x00000001 0x3fca2df8
    [13:28:54]3fca4e30: 0x706f6f6c 0x6b736154 0xeb0c1000 0x00826051 0x00000000 0x3fca4df0 0x00000001 0x00000000
    [13:28:54]3fca4e50: 0x3fca933c 0x4207636c 0x0000000b 0x3fc9ee3c 0x3fc9eea4 0x3fc9ef0c 0x00000000 0x00000000
    [13:28:54]3fca4e70: 0x00000001 0x00000000 0x00000000 0x00000000 0x420e6884 0x00000000 0x00000000 0x00000000
    [13:28:54]3fca4e90: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
    [13:28:54]3fca4eb0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
    [13:28:54]3fca4ed0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
    [13:28:54]3fca4ef0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
    [13:28:54]3fca4f10: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
    [13:28:54]3fca4f30: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x3f000000
    [13:28:54]3fca4f50: 0x00000054 0x00000000 0x3fca4f54 0x00000000 0x00000000 0x00000000 0x3fca4f6c 0xffffffff
    [13:28:54]3fca4f70: 0x3fca4f6c 0x3fca4f6c 0x00000000 0x3fca4f80 0xffffffff 0x3fca4f80 0x3fca4f80 0x00000001
    [13:28:54]3fca4f90: 0x00000001 0x00000000 0xc000ffff 0x00000000 0xb33fffff 0x00000000 0x00000054 0x3fca4fac
    [13:28:54]3fca4fb0: 0x3fca4fac 0x3fca4fac 0x3fca4fac 0x00000000 0x3fca4fc4 0xffffffff 0x3fca4fc4 0x3fca4fc4
    [13:28:54]3fca4fd0: 0x00000000 0x3fca4fd8 0xffffffff 0x3fca4fd8 0x3fca4fd8 0x00000000 0x7fffffff 0x00000000
    [13:28:54]3fca4ff0: 0x4d00ffff 0x00000000 0xb33fffff 0x00000000 0x0000004c 0x00ffa000 0x00000000 0x00000000
    [13:28:54]3fca5010: 0x001e0000 0x00010000 0x02050000 0x7fff0001 0x8080021b 0x00108080 0x00000000 0x00005639
    [13:28:54]3fca5030: 0x00005579 0x00000b40 0x000a0003 0x50000324 0x5000022c 0x00000004 0x00000106 0x00000000
    [13:28:54]3fca5050: 0x00000054 0x00000000 0x3fca5054 0x00000000 0x00000000 0x00000000 0x3fca506c 0xffffffff
    [13:28:54]3fca5070: 0x3fca506c 0x3fca506c 0x00000000 0x3fca5080 0xffffffff 0x3fca5080 0x3fca5080 0x00000001
    [13:28:54]3fca5090: 0x00000001 0x00000000 0x0000ffff 0x00000000 0xb33fffff 0x00000000 0x0000008c 0x00000000
    [13:28:54]3fca50b0: 0x4208361a 0x00000000 0x4208334c 0x00000000 0x00000000 0x00000000 0x42083146 0x42093b1a
    [13:28:54]3fca50d0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
    [13:28:54]3fca50f0: 0x00000000 0x00000000 0x00000000 0x00000000 0x42093b06 0x42093af0 0x00000000 0x00000000
    [13:28:54]3fca5110: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0xffffffff
    [13:28:54]3fca5130: 0x00000000 0x00000004 0x00000010 0x3fcb5d24 0x000056a6 0x4208a736 0x3c1242b0 0x00000010
    [13:28:54]
    [13:28:54]
    [13:28:54]
    [13:28:54]ELF file SHA256: 0000000000000000```
    
  6. DedeHai commented on Dec 17, 2025

    @DedeHai
    Collaborator

    I can get it to run without crashing, I just need to check on how to properly fix it. If you want to try: change this line

    palettes_qstrings = re_findModeStrings(JSON_palette_names, getPaletteCount());

    to palettes_qstrings = re_findModeStrings(JSON_palette_names, getPaletteCount()+1);

  7. DedeHai commented on Dec 17, 2025

    @DedeHai
    Collaborator

    I fixed this line in main, please try it once it is available in nightly build tomorrow.

  8. softhack007 commented on Dec 17, 2025

    @softhack007
    Member

    @DedeHai I am not sure that your fix in 624763c is correct 🤔

    This is very old code, that was written before custom palettes were added. I've tried to understand the old stuff (with some AI help), and i think the correct fix would be to exclude custom palettes in the call

      palettes_qstrings = re_findModeStrings(JSON_palette_names, getPaletteCount() - customPalettes.size() + 1);

    AI analysis (might be wrong, but looks sound to me)

    • The palettes JSON list includes an extra “Default” entry at index 0.
    • getPaletteCount() returns fixed palettes plus custom palettes, but the JSON source only contains the fixed palettes; it doesn’t include the custom ones.
    • FIXED_PALETTE_COUNT explicitly excludes “Default” (see comments in const.h), so the number of entries in JSON_palette_names is FIXED_PALETTE_COUNT + 1 (accounting for “Default”).
    • We need to ensure the allocated pointer array matches the JSON source (fixed + “Default”), preventing out-of-bounds writes and crashes. But custom palettes should be excluded, because they are not listed in JSON_palette_names.

    Edit: the - customPalettes.size()part seems "optional" to me. numModes is only used to allocate an array, then the loop runs over JSON_palette_names. So it should not matter much if extra entries for custom palettes are added, because these will not considered in re_findModeStrings().

    However the code in re_findModeStrings() should be improved to check array bounds before writing into the modeStrings arrays.

  9. DedeHai commented on Dec 18, 2025

    @DedeHai
    Collaborator

    I did track it down with serial prints, that one-off was definitely wrong. I am wondering if this was ever correct and why we only see this issue now.
    I agree there should be bound-checks, there are other places that don't do any checks so the whole usermod is fragile.

  10. softhack007 commented on Dec 18, 2025

    @softhack007
    Member

    @DedeHai true, I can remember that the rotary usermod -especially the effects and palettes sorting part - was always kind of fragile, but we never had the time to really understand the root cause.

    I've looked into "my" codebase in WLED-MM - 1-2 years behind upstream - and found no off-by-one problem there. It looks like getPaletteCount() was changed at some time to "skip" slot 0 for the default palette.

    We might actually have a bigger problem here... older features - like irremote, Alexa, and a bunch of usermods - might still assume the previous behaviour of getPaletteCount(), leading to possibly more off-by-one problems in these features.

    Lessons learned: never change a public API - better to rename the function if it does not behave like before...

  11. blazoncek commented on Dec 20, 2025

    @blazoncek
    Contributor

    @softhack007 is correct, FIXED_PALETTE_COUNT is off by one but that is not all.
    Quicksort will also wreck havoc in there.

    See: blazoncek@167cb06

    I is interesting to note that original code will not crash on ESP32.

  12. added a commit that references this issue on Dec 20, 2025
  13. added a commit that references this issue on Jan 3, 2026
  14. added
    fixed in source
    on Jan 7, 2026
  15. added a commit that references this issue on Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugconfirmedfixed in source

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions