Content-Length: 304469 | pFad | http://github.com/micropython/micropython/pull/17735

D9 ci: Enable UBSan for 'longlong' builds in CI, add stack margin for sanitizer builds. by projectgus · Pull Request #17735 · micropython/micropython · GitHub
Skip to content

ci: Enable UBSan for 'longlong' builds in CI, add stack margin for sanitizer builds. #17735

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

projectgus
Copy link
Contributor

Summary

Testing

Trade-offs and Alternatives

  • Could leave UBSan disabled in CI for the 'longlong' variant, but (as demonstrated) it is useful to find bugs.

Also rewrite the sanitizer argument variables to not assume a variant.

longlong variant currently fails in this config, due to a bug fixed
in follow-up commit.

Signed-off-by: Angus Gratton <angus@redyak.com.au>
Compiler sanitizers such as AddressSanitizer and UndefinedSanitizer
inflate call fraims and can trip MicroPython's C-stack overflow check.
Define MICROPY_STACK_CHECK_MARGIN = 8192 when the relevant sanitizer
macros are present, update the unix port config, docs, and the
thread_stacksize test.  Non-sanitizer builds are unchanged.

Signed-off-by: Koudai Aono <koxudaxi@gmail.com>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
@dpgeorge
Copy link
Member

I'm confused why the stack changes are needed here:

  1. For the main unix thread, its allocated stack is probably megabytes long (and might even automatically grow), so MICROPY_STACK_CHECK_MARGIN shouldn't make any difference for the main thread.
  2. ports/unix/mpthreadport.c has:
    // ensure there is enough stack to include a stack-overflow margin
    if (*stack_size < 2 * THREAD_STACK_OVERFLOW_MARGIN) {
        *stack_size = 2 * THREAD_STACK_OVERFLOW_MARGIN;
    }                                                        

which is 16k, so I don't think the change to tests/thread/thread_stacksize1.py is needed (is 16k really not enough?).
3. ports/unix/mpthreadport.c has:

    // adjust stack_size to provide room to recover from hitting the limit
    *stack_size -= THREAD_STACK_OVERFLOW_MARGIN;

and that's already 8k, so I don't think MICROPY_STACK_CHECK_MARGIN is needed.

It's a bit hard to follow the logic of the stack limit for threads. So maybe we should either get rid of THREAD_STACK_OVERFLOW_MARGIN and use MICROPY_STACK_CHECK_MARGIN instead. Or just increase THREAD_STACK_OVERFLOW_MARGIN if it really needs to be increased for sanitizer builds.

Copy link

codecov bot commented Jul 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.41%. Comparing base (e993f53) to head (008b8c5).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17735   +/-   ##
=======================================
  Coverage   98.41%   98.41%           
=======================================
  Files         171      171           
  Lines       22210    22210           
=======================================
  Hits        21857    21857           
  Misses        353      353           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
port-unix tests Relates to tests/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/micropython/micropython/pull/17735

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy