File tree Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Expand file tree Collapse file tree 4 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -2644,8 +2644,10 @@ LibraryManager.library = {
2644
2644
{ { { makeEval ( 'return eval ( UTF8ToString ( ptr ) ) | 0 ; ') } } }
2645
2645
} ,
2646
2646
2647
- emscripten_run_script_string__sig : 'ii ',
2647
+ // We use builtin_malloc and builtin_free here because otherwise lsan will
2648
+ // report the last returned string as a leak.
2648
2649
emscripten_run_script_string__deps : [ 'emscripten_builtin_malloc ', 'emscripten_builtin_free '] ,
2650
+ emscripten_run_script_string__sig : 'ii ',
2649
2651
emscripten_run_script_string : function ( ptr ) {
2650
2652
{ { { makeEval ( "var s = eval(UTF8ToString(ptr));" ) } } }
2651
2653
if ( s == null ) {
@@ -2930,6 +2932,8 @@ LibraryManager.library = {
2930
2932
_emscripten_log_js ( flags , str ) ;
2931
2933
} ,
2932
2934
2935
+ // We never free the return values of this function so we need to allocate
2936
+ // using builtin_malloc to avoid LSan reporting these as leaks.
2933
2937
emscripten_get_compiler_setting__deps : [ 'emscripten_builtin_malloc' ] ,
2934
2938
emscripten_get_compiler_setting : function ( name ) {
2935
2939
#if RETAIN_COMPILER_SETTINGS
Original file line number Diff line number Diff line change 1
1
#include "libc.h"
2
2
3
- #ifdef __EMSCRIPTEN__
4
- #include <stdlib.h>
5
- #include <wasi/api.h>
6
- #include <emscripten/emmalloc.h>
7
- #endif
8
-
9
3
char * * __environ = 0 ;
10
4
weak_alias (__environ , ___environ );
11
5
weak_alias (__environ , _environ );
12
6
weak_alias (__environ , environ );
13
7
14
8
#ifdef __EMSCRIPTEN__
9
+ #include <stdlib.h>
10
+ #include <wasi/api.h>
11
+ // Included for emscripten_builtin_free / emscripten_builtin_malloc
12
+ // TODO(sbc): Should these be in their own header to avoid emmalloc here?
13
+ #include <emscripten/emmalloc.h>
14
+
15
+ // We use emscripten_builtin_malloc here because this memory is never freed and
16
+ // and we don't want LSan to consider this a leak.
15
17
__attribute__((constructor (100 ))) // construct this before user code
16
18
void __emscripten_environ_constructor (void ) {
17
19
size_t environ_count ;
Original file line number Diff line number Diff line change 5
5
* found in the LICENSE file.
6
6
*/
7
7
8
+ // Included for emscripten_builtin_free / emscripten_builtin_malloc
9
+ // TODO(sbc): Should these be in their own header to avoid emmalloc here?
8
10
#include <emscripten/emmalloc.h>
9
11
#include <pthread.h>
10
12
Original file line number Diff line number Diff line change 13
13
#include <stdbool.h>
14
14
#include <string.h>
15
15
#include <threads.h>
16
+ // Included for emscripten_builtin_free / emscripten_builtin_malloc
17
+ // TODO(sbc): Should these be in their own header to avoid emmalloc here?
16
18
#include <emscripten/emmalloc.h>
17
19
18
20
// See musl's pthread_create.c
You can’t perform that action at this time.
0 commit comments