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

valgrind warning in sslcontext_dtor when running ./src/AtomVM ./tests/libs/estdlib/test_estdlib.avm on CI #1115

Closed
bettio opened this issue Mar 9, 2024 · 0 comments

Comments

@bettio
Copy link
Collaborator

bettio commented Mar 9, 2024

Following warning has been taken from CI output.

See also https://github.com/atomvm/AtomVM/actions/runs/8214411234/job/22466885128?pr=1114

==13113== Memcheck, a memory error detector
==13113== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==13113== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==13113== Command: ./src/AtomVM ./tests/libs/estdlib/test_estdlib.avm
==13113== 
--13113-- WARNING: unhandled x86-linux syscall: 403
--13113-- You may be able to write your own handler.
--13113-- Read the file README_MISSING_SYSCALL_OR_IOCTL.
--13113-- Nevertheless we consider this a bug.  Please report
--13113-- it at http://valgrind.org/support/bug_reports.html.
E otp_socket: Unable to send data: res=-2. (/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.c:2151)
E otp_socket: Unable to send data: res=-2. (/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.c:2151)
E otp_socket: socket:setopt: Unsupported otp option (/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.c:1127)
E otp_socket: socket:setopt: otp rcvbuf value must be an integer (/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.c:1113)
E otp_socket: socket:setopt: otp rcvbuf value may not be negative (/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.c:1119)
I otp_socket: Peer closed connection. (/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.c:1800)
I otp_socket: Peer closed connection. (/home/runner/work/AtomVM/AtomVM/src/libAtomVM/otp_socket.c:1800)
{warning,timeout,waiting,accept_terminated}
WARNING: EAI_SERVICE unsupported on this platform.
WARNING: EAI_SERVICE unsupported on this platform.
WARNING: EAI_SERVICE unsupported on this platform.
==13113== Invalid read of size 4
==13113==    at 0x49814D7: mbedtls_debug_print_msg (in /usr/lib/i386-linux-gnu/libmbedtls.so.2.16.3)
==13113==    by 0x4991EBF: mbedtls_ssl_free (in /usr/lib/i386-linux-gnu/libmbedtls.so.2.16.3)
==13113==    by 0x1A803C: sslcontext_dtor (otp_ssl.c:129)
==13113==    by 0x18F167: refc_binary_destroy (refc_binary.c:88)
==13113==    by 0x18F167: refc_binary_decrement_refcount (refc_binary.c:70)
==13113==    by 0x16228F: memory_sweep_mso_list (memory.c:735)
==13113==    by 0x16228F: memory_gc (memory.c:296)
==13113==    by 0x1626CA: memory_ensure_free_with_roots (memory.c:176)
==13113==    by 0x113F87: scheduler_entry_point (opcodesswitch.h:2303)
==13113==    by 0x1126B2: main (main.c:148)
==13113==  Address 0x4ff7c3c is 36 bytes inside a block of size 228 free'd
==13113==    at 0x48388AB: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-x86-linux.so)
==13113==    by 0x18F173: refc_binary_destroy (refc_binary.c:91)
==13113==    by 0x18F173: refc_binary_decrement_refcount (refc_binary.c:70)
==13113==    by 0x1A8030: sslcontext_dtor (otp_ssl.c:127)
==13113==    by 0x18F167: refc_binary_destroy (refc_binary.c:88)
==13113==    by 0x18F167: refc_binary_decrement_refcount (refc_binary.c:70)
==13113==    by 0x16228F: memory_sweep_mso_list (memory.c:735)
==13113==    by 0x16228F: memory_gc (memory.c:296)
==13113==    by 0x1626CA: memory_ensure_free_with_roots (memory.c:176)
==13113==    by 0x113F87: scheduler_entry_point (opcodesswitch.h:2303)
==13113==    by 0x1126B2: main (main.c:148)
==13113==  Block was alloc'd at
==13113==    at 0x483767F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-x86-linux.so)
==13113==    by 0x18F02C: refc_binary_create_resource (refc_binary.c:39)
==13113==    by 0x18F4DE: enif_alloc_resource (resources.c:66)
==13113==    by 0x1A7AFF: nif_ssl_config_init (otp_ssl.c:339)
==13113==    by 0x126F95: scheduler_entry_point (opcodesswitch.h:1898)
==13113==    by 0x1A0083: scheduler_thread_entry_point (smp.c:75)
==13113==    by 0x4A28634: start_thread (pthread_create.c:477)
==13113==    by 0x4B48B49: clone (clone.S:108)
==13113== 
==13113== Invalid read of size 4
==13113==    at 0x49814D7: mbedtls_debug_print_msg (in /usr/lib/i386-linux-gnu/libmbedtls.so.2.16.3)
==13113==    by 0x4991FD2: mbedtls_ssl_free (in /usr/lib/i386-linux-gnu/libmbedtls.so.2.16.3)
==13113==    by 0x1A803C: sslcontext_dtor (otp_ssl.c:129)
==13113==    by 0x18F167: refc_binary_destroy (refc_binary.c:88)
==13113==    by 0x18F167: refc_binary_decrement_refcount (refc_binary.c:70)
==13113==    by 0x16228F: memory_sweep_mso_list (memory.c:735)
==13113==    by 0x16228F: memory_gc (memory.c:296)
==13113==    by 0x1626CA: memory_ensure_free_with_roots (memory.c:176)
==13113==    by 0x113F87: scheduler_entry_point (opcodesswitch.h:2303)
==13113==    by 0x1126B2: main (main.c:148)
==13113==  Address 0x4ff7c3c is 36 bytes inside a block of size 228 free'd
==13113==    at 0x48388AB: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-x86-linux.so)
==13113==    by 0x18F173: refc_binary_destroy (refc_binary.c:91)
==13113==    by 0x18F173: refc_binary_decrement_refcount (refc_binary.c:70)
==13113==    by 0x1A8030: sslcontext_dtor (otp_ssl.c:127)
==13113==    by 0x18F167: refc_binary_destroy (refc_binary.c:88)
==13113==    by 0x18F167: refc_binary_decrement_refcount (refc_binary.c:70)
==13113==    by 0x16228F: memory_sweep_mso_list (memory.c:735)
==13113==    by 0x16228F: memory_gc (memory.c:296)
==13113==    by 0x1626CA: memory_ensure_free_with_roots (memory.c:176)
==13113==    by 0x113F87: scheduler_entry_point (opcodesswitch.h:2303)
==13113==    by 0x1126B2: main (main.c:148)
==13113==  Block was alloc'd at
==13113==    at 0x483767F: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-x86-linux.so)
==13113==    by 0x18F02C: refc_binary_create_resource (refc_binary.c:39)
==13113==    by 0x18F4DE: enif_alloc_resource (resources.c:66)
==13113==    by 0x1A7AFF: nif_ssl_config_init (otp_ssl.c:339)
==13113==    by 0x126F95: scheduler_entry_point (opcodesswitch.h:1898)
==13113==    by 0x1A0083: scheduler_thread_entry_point (smp.c:75)
==13113==    by 0x4A28634: start_thread (pthread_create.c:477)
==13113==    by 0x4B48B49: clone (clone.S:108)
==13113== 
CRASH 
======
pid: <0.37.0>

Stacktrace:
undefined

cp: #CP<module: 15, label: 92, offset: 23>

x[0]: throw
x[1]: test_crash
x[2]: throw

Stack 
------

[]
[]
{state,0,0,0,none,false}
[]
[]
{state,undefined,test_gen_server,{state,0,0,0,none,false}}
#CP<module: 15, label: 120, offset: 0>


Mailbox
--------


Monitors
--------
<0.32.0> <---> <0.37.0>


**End Of Crash Report**
bettio added a commit that referenced this issue Apr 18, 2024
Fix order of free functions for ssl context/drbg

Documentation specifies that mbedtls_ssl_config_free and mbedtls_entropy_free
should be called after mbedtls_ssl_free and mbedtsl_ctr_drbg_free.

Fixes #1115.

These changes are made under both the "Apache 2.0" and the "GNU Lesser General
Public License 2.1 or later" license terms (dual license).

SPDX-License-Identifier: Apache-2.0 OR LGPL-2.1-or-later
@bettio bettio closed this as completed in fb53099 Apr 23, 2024
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

1 participant