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

[embassy-sync] Using Watch, probe-rs and a --release build leads to an exception #3537

Open
lure23 opened this issue Nov 14, 2024 · 3 comments

Comments

@lure23
Copy link

lure23 commented Nov 14, 2024

I started using the new Watch functionality today. Unfortunately, haven't been able to see it work in release builds, yet. This happens:

3.559229 [INFO ] Init succeeded
3.905247 [ERROR] Exception 'Load access fault' mepc=0x42004a1e, mtval=0x4d421b00
3.905345 [ERROR] TrapFrame { ra: 1107327136, t0: 3905200, t1: 0, t2: 0, t3: 2181074082, t4: 0, t5: 0, t6: 0, a0: 1082556352, a1: 1, a2: 1, a3: 4, a4: 1107315144, a5: 1082171792, a6: 0, a7: 0, s0: 1082577216, s1: 2328, s2: 1082170664, s3: 4, s4: 4096, s5: 1082169368, s6: 0, s7: 1082579628, s8: 1296177920, s9: 1082169344, s10: 1082168999, s11: 1082169304, gp: 1082134720, tp: 0, sp: 1082577136, pc: 1107315230, mstatus: 6273, mcause: 5, mtval: 1296177920 }
3.905661 [ERROR] 0x4200789c
3.905693 [ERROR] 0x42009c40
3.905725 [ERROR] 0x42001264
3.905757 [ERROR] 0x420021b6
3.905789 [ERROR] 0x4200675c
3.905821 [ERROR] 0x42004894
3.905853 [ERROR] 0x42004650
3.905885 [ERROR] 0x4200c312
3.905917 [ERROR] 0x42000132

If I change to non---release (wanted to see the symbols in the stack trace), All is Fine.

I presume this is caused by inclusion of embassy-sync - I didn't change other dependencies, today.

Don't have a Minimal Repo, but my source is available here - note the tof branch.

Steps

  • git clone [email protected]:lure23/Zoo-ESP32_Cx.git

    $ cd Zoo-*
    $ git checkout tof
    
  • Read the README at the top and tof levels.

    This is likely beyond anyone wants to do, to repeat the problem. You'd need to set up tools, bring in vendor C sources... Oh, and you need VL53L5CX hardware! 🫠🎈🎈

  • _

    $ cd tof/vl53l5cx
    $ make -f Makefile.dev m
    

Expected

The program runs and presents some results.

Actual

Above pasted exception.

Further info

If we compile it without --release (or not use probe-rs, see comments), all is fine:

$ make -f Makefile.dev m-dev
[...]
4.313160 [INFO ] Data #0: (30°C, 0ms)
4.313230 [INFO ] .target_status:    [[[Valid, Valid, Valid, SemiValid(9)], [Valid, Valid, SemiValid(9), Valid], [Valid, Valid, Valid, Valid], [Valid, Valid, Valid, Valid]]]
4.313369 [INFO ] .distance_mm:      [[[581, 685, 766, 1002], [850, 781, 997, 1038], [961, 641, 783, 1624], [645, 728, 780, 769]]]
@lure23 lure23 changed the title [embassy-sync] Using Watch, built with --release leads to "Exception 'Load access fault'" [embassy-sync] Using Watch, built with --release leads to Exception 'Load access fault' Nov 14, 2024
@lure23
Copy link
Author

lure23 commented Nov 14, 2024

The exception happens on this line, i.e. where the Watch is read/waited upon.

Using e.g. .get() instead of the .changed() gives the same behaviour.


What I would need to do is a minimum viable reproduction, but likely I'll just use non-release build and carry on. Perhaps later.

@lure23 lure23 changed the title [embassy-sync] Using Watch, built with --release leads to Exception 'Load access fault' [embassy-sync] Using Watch on --release build leads to an exception Nov 15, 2024
@lure23
Copy link
Author

lure23 commented Nov 15, 2024

Updated the bug description on my own repo (a full rewrite).

The issue occurs with the combination of:

  • probe-rs
  • --release build
  • embassy-sync - at least Watch mechanism, both .changed() and .get()

Running the code with espflash succeeds in both --release and default modes.

@lure23 lure23 changed the title [embassy-sync] Using Watch on --release build leads to an exception [embassy-sync] Using Watch, probe-rs and a --release build leads to an exception Nov 15, 2024
@peterkrull
Copy link
Contributor

Hmm, I have not had any issues with extensive usage (e.g. RP2040, STM32, std, multi-core, interrupts). Could you try replacing the Watch with another channel, e.g. a PubSubChannel with a depth of 1? Just to see if the crash can be triggered without the Watch. Also as far as I can tell 'Load access fault' has something to do with incorrectly accessed memory, and your // Something brings in need for global allocator. Fake it!!! seems a bit spooky to me. Could you try using an actual allocator?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants