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

Assertion failure in esp_bignum (IDFGH-11507) #12632

Closed
3 tasks done
xing35 opened this issue Nov 20, 2023 · 2 comments
Closed
3 tasks done

Assertion failure in esp_bignum (IDFGH-11507) #12632

xing35 opened this issue Nov 20, 2023 · 2 comments
Assignees
Labels
Resolution: Cannot Reproduce Issue cannot be reproduced Status: Done Issue is done internally Type: Bug bugs in IDF

Comments

@xing35
Copy link

xing35 commented Nov 20, 2023

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.0

Espressif SoC revision.

ESP32-D0WDR2-V3-V3 (revision v3.0)

Operating System used.

Windows

How did you build your project?

Command line with idf.py

If you are using Windows, please specify command line type.

CMD

Development Kit.

Custom Board

Power Supply used.

Battery

What is the expected behavior?

No panic

What is the actual behavior?

We encountered panic described in #11850, so backported 8e25eb1. We start to observe new assertion failure that seems related.

system panic with

assert failed: mpi_mult_mpi_failover_mod_mult esp_bignum.c:662 ((z_words >= mpi_words(Z)) && (z_words - mpi_words(Z) <= (size_t)1))

Steps to reproduce.

This could happen when esp32 communicates with an https server, sending a request every 0.5s. And/or when a https client sends request to esp32 every 3-5s

Debug Logs.

assert failed: mpi_mult_mpi_failover_mod_mult esp_bignum.c:662 ((z_words >= mpi_words(Z)) && (z_words - mpi_words(Z) <= (size_t)1))  

Backtrace: 0x40082726:0x3ffcadd0 0x4008cef5:0x3ffcadf0 0x40096bba:0x3ffcae10 0x40133e83:0x3ffcaf30 0x40133f61:0x3ffcaf60 0x401287b4:0x3ffcaf90 0x40128972:0x3ffcb030 0x40133a41:0x3ffcb060 0x40133b62:0x3ffcb090 0x40131dd7:0x3ffcb120 0x40132ca0:0x3ffcb150 0x40132d0a:0x3ffcb180 0x4012fe63:0x3ffcb1b0 0x4012fb45:0x3ffcb1e0 0x40125400:0x3ffcb200 0x40123567:0x3ffcb2a0 0x401235c0:0x3ffcb2c0 0x4011a711:0x3ffcb2e0 0x4011a1e1:0x3ffcb300 0x4011a2db:0x3ffcb350 0x40171b8b:0x3ffcb380 0x40197275:0x3ffcb3b0 0x4011eb9e:0x3ffcb3d0 0x4011efc5:0x3ffcb3f00x40104be7:0x3ffcb420 0x401053d3:0x3ffcb450 0x401060e4:0x3ffcb6e0 0x400d9ade:0x3ffcb7a0

0x40082726: panic_abort at /esp-idf/components/esp_system/panic.c:412

0x4008cef5: esp_system_abort at /esp-idf/components/esp_system/esp_system.c:135

0x40096bba: __assert_func at /esp-idf/components/newlib/assert.c:78

0x40133e83: mpi_mult_mpi_failover_mod_mult at /esp-idf/components/mbedtls/port/esp_bignum.c:662
 (inlined by) mbedtls_mpi_mul_mpi at /esp-idf/components/mbedtls/port/esp_bignum.c:522

0x40133f61: mbedtls_mpi_mul_int at /esp-idf/components/mbedtls/port/esp_bignum.c:557

0x401287b4: mbedtls_mpi_div_mpi at /esp-idf/components/mbedtls/mbedtls/library/bignum.c:1690

0x40128972: mbedtls_mpi_mod_mpi at /esp-idf/components/mbedtls/mbedtls/library/bignum.c:1760

0x40133a41: calculate_rinv at /esp-idf/components/mbedtls/port/esp_bignum.c:200 (discriminator 2)

0x40133b62: esp_mpi_exp_mod at /esp-idf/components/mbedtls/port/esp_bignum.c:388
 (inlined by) mbedtls_mpi_exp_mod at /esp-idf/components/mbedtls/port/esp_bignum.c:460

0x40131dd7: mbedtls_rsa_public at /esp-idf/components/mbedtls/mbedtls/library/rsa.c:763

0x40132ca0: mbedtls_rsa_rsassa_pkcs1_v15_verify at /esp-idf/components/mbedtls/mbedtls/library/rsa.c:2154

0x40132d0a: mbedtls_rsa_pkcs1_verify at /esp-idf/components/mbedtls/mbedtls/library/rsa.c:2206

0x4012fe63: rsa_verify_wrap at /esp-idf/components/mbedtls/mbedtls/library/pk_wrap.c:247

0x4012fb45: mbedtls_pk_verify_restartable at /esp-idf/components/mbedtls/mbedtls/library/pk.c:441

0x40125400: ssl_parse_server_key_exchange at /esp-idf/components/mbedtls/mbedtls/library/ssl_tls12_client.c:2512
 (inlined by) mbedtls_ssl_handshake_client_step at /esp-idf/components/mbedtls/mbedtls/library/ssl_tls12_client.c:3663

0x40123567: mbedtls_ssl_handshake_step at /esp-idf/components/mbedtls/mbedtls/library/ssl_tls.c:3027
 (inlined by) mbedtls_ssl_handshake_step at /esp-idf/components/mbedtls/mbedtls/library/ssl_tls.c:2984

0x401235c0: mbedtls_ssl_handshake at /esp-idf/components/mbedtls/mbedtls/library/ssl_tls.c:3092
 (inlined by) mbedtls_ssl_handshake at /esp-idf/components/mbedtls/mbedtls/library/ssl_tls.c:3068

0x4011a711: esp_mbedtls_handshake at /esp-idf/components/esp-tls/esp_tls_mbedtls.c:192

0x4011a1e1: esp_tls_handshake at /esp-idf/components/esp-tls/esp_tls.c:83 (discriminator 15)
 (inlined by) esp_tls_low_level_conn at /esp-idf/components/esp-tls/esp_tls.c:437 (discriminator 15)

0x4011a2db: esp_tls_conn_new_sync at /esp-idf/components/esp-tls/esp_tls.c:464

0x40171b8b: ssl_connect at /esp-idf/components/tcp_transport/transport_ssl.c:109

0x40197275: esp_transport_connect at /esp-idf/components/tcp_transport/transport.c:123

0x4011eb9e: esp_http_client_connect at /esp-idf/components/esp_http_client/esp_http_client.c:1283

0x4011efc5: esp_http_client_perform at /esp-idf/components/esp_http_client/esp_http_client.c:1130

0x40104be7: cad::HttpClient::perform() at /tmp/build/80754af9/source/managed_components/rest_client/include/HttpClient.hpp:110
 (inlined by) cad::RestClient::odu_send(char const*, esp_http_client_method_t) at /tmp/build/80754af9/source/managed_components/rest_client/RestClient.cpp:266

0x401053d3: cad::RestClient::odu_hello() at /tmp/build/80754af9/source/managed_components/rest_client/include/RestClient.hpp:73
 (inlined by) cad::RestClient::odu_sync(unsigned long) at /tmp/build/80754af9/source/managed_components/rest_client/RestClient.cpp:189

0x401060e4: cad::RestClient::odu_sync(unsigned long) at /tmp/build/80754af9/source/managed_components/rest_client/RestClient.cpp:174
 (inlined by) cad::RestClient::run() at /tmp/build/80754af9/source/managed_components/rest_client/RestClient.cpp:616

0x400d9ade: cad::TaskComponent::run_task(void*) at /tmp/build/80754af9/source/managed_components/component_base/include/TaskComponent.hpp:70




assert failed: mpi_mult_mpi_failover_mod_mult esp_bignum.c:662 ((z_words >= mpi_words(Z)) && (z_words - mpi_words(Z) <= (size_t)1))


Backtrace: 0x40082726:0x3ffd9a80 0x4008cef5:0x3ffd9aa0 0x40096bba:0x3ffd9ac0 0x4012c97b:0x3ffd9be0 0x4012ca59:0x3ffd9c10 0x401212f4:0x3ffd9c40 0x401214b2:0x3ffd9ce0 0x4012aa60:0x3ffd9d10 0x4012b480:0x3ffd9de0 0x4012b529:0x3ffd9e00 0x40128979:0x3ffd9e30 0x40128805:0x3ffd9e60 0x4011f1f1:0x3ffd9e90 0x4011c0cb:0x3ffd9fc0 0x4011c108:0x3ffd9fe0 0x40113a4f:0x3ffda000 0x40111e35:0x3ffda030 0x400f16cc:0x3ffda050 0x40119c52:0x3ffda080 0x40118771:0x3ffda0e0
0x40082726: panic_abort at C:/Users/emily.xing/esp/esp-idf/components/esp_system/panic.c:412

0x4008cef5: esp_system_abort at C:/Users/emily.xing/esp/esp-idf/components/esp_system/esp_system.c:135

0x40096bba: __assert_func at C:/Users/emily.xing/esp/esp-idf/components/newlib/assert.c:78

0x4012c97b: mpi_mult_mpi_failover_mod_mult at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/port/esp_bignum.c:662
 (inlined by) mbedtls_mpi_mul_mpi at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/port/esp_bignum.c:522

0x4012ca59: mbedtls_mpi_mul_int at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/port/esp_bignum.c:557

0x401212f4: mbedtls_mpi_div_mpi at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/bignum.c:1690

0x401214b2: mbedtls_mpi_mod_mpi at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/bignum.c:1760

0x4012aa60: rsa_prepare_blinding at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/rsa.c:818
 (inlined by) mbedtls_rsa_private at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/rsa.c:964

0x4012b480: mbedtls_rsa_rsassa_pkcs1_v15_sign at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/rsa.c:1883
 (inlined by) mbedtls_rsa_rsassa_pkcs1_v15_sign at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/rsa.c:1838

0x4012b529: mbedtls_rsa_pkcs1_sign at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/rsa.c:1927

0x40128979: rsa_sign_wrap at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/pk_wrap.c:357

0x40128805: mbedtls_pk_sign_restartable at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/pk.c:627
 (inlined by) mbedtls_pk_sign at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/pk.c:641

0x4011f1f1: ssl_prepare_server_key_exchange at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/ssl_tls12_server.c:3177
 (inlined by) ssl_write_server_key_exchange at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/ssl_tls12_server.c:3251
 (inlined by) mbedtls_ssl_handshake_server_step at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/ssl_tls12_server.c:4358

0x4011c0cb: mbedtls_ssl_handshake_step at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/ssl_tls.c:3044
 (inlined by) mbedtls_ssl_handshake_step at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/ssl_tls.c:2984

0x4011c108: mbedtls_ssl_handshake at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/ssl_tls.c:3092
 (inlined by) mbedtls_ssl_handshake at C:/Users/emily.xing/esp/esp-idf/components/mbedtls/mbedtls/library/ssl_tls.c:3068

0x40113a4f: esp_mbedtls_server_session_create at C:/Users/emily.xing/esp/esp-idf/components/esp-tls/esp_tls_mbedtls.c:796

0x40111e35: esp_tls_server_session_create at C:/Users/emily.xing/esp/esp-idf/components/esp-tls/esp_tls.c:611

0x400f16cc: httpd_ssl_open at C:/Users/emily.xing/esp/esp-idf/components/esp_https_server/src/https_server.c:126 (discriminator 13)

0x40119c52: httpd_sess_new at C:/Users/emily.xing/esp/esp-idf/components/esp_http_server/src/httpd_sess.c:212

0x40118771: httpd_accept_conn at C:/Users/emily.xing/esp/esp-idf/components/esp_http_server/src/httpd_main.c:65
 (inlined by) httpd_server at C:/Users/emily.xing/esp/esp-idf/components/esp_http_server/src/httpd_main.c:256
 (inlined by) httpd_thread at C:/Users/emily.xing/esp/esp-idf/components/esp_http_server/src/httpd_main.c:272

More Information.

could disable CONFIG_MBEDTLS_HARDWARE_MPI as a workaround

@xing35 xing35 added the Type: Bug bugs in IDF label Nov 20, 2023
@github-actions github-actions bot changed the title Assertion failure in esp_bignum Assertion failure in esp_bignum (IDFGH-11507) Nov 20, 2023
@espressif-bot espressif-bot added the Status: Opened Issue is new label Nov 20, 2023
@laukik-hase
Copy link
Collaborator

Hello, @xing35!

Thank you for the issue report.

Sorry for the late response - could you please attach the following -

  • The sdkconfig file for your example
  • Minimal example that produces the issue
  • Could you also test this minimal example with the v5.0.4 tag?
    • Also, try the example after cherry-picking the commit 521dd35 on the v5.0.4 tag (this commit just updates the assert but does not change its function)

@espressif-bot espressif-bot added Status: In Progress Work is in progress and removed Status: Opened Issue is new labels Dec 1, 2023
@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Cannot Reproduce Issue cannot be reproduced and removed Status: In Progress Work is in progress labels Dec 19, 2023
@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting, will close due to short of feedback, feel free to reopen with more updates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Cannot Reproduce Issue cannot be reproduced Status: Done Issue is done internally Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

4 participants