Skip to content

Commit

Permalink
Asan: Refine asan warning message for macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Dec 31, 2022
1 parent 7750bda commit 7bdb727
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions trunk/auto/auto_headers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ if [[ $SRS_GPERF_CP == YES ]]; then
else
srs_undefine_macro "SRS_GPERF_CP" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_SANITIZER == YES ]; then
srs_define_macro "SRS_SANITIZER" $SRS_AUTO_HEADERS_H
else
srs_undefine_macro "SRS_SANITIZER" $SRS_AUTO_HEADERS_H
fi
if [ $SRS_SANITIZER_LOG == YES ]; then
srs_define_macro "SRS_SANITIZER_LOG" $SRS_AUTO_HEADERS_H
else
Expand Down
2 changes: 2 additions & 0 deletions trunk/configure
Original file line number Diff line number Diff line change
Expand Up @@ -586,13 +586,15 @@ ffmpeg:
END

# Generate Makefile entry for srs-server.
cat << END >> ${SRS_MAKEFILE}
server: _prepare_dir
@echo "Build the SRS server, JOBS=\${JOBS}, FORCE_MAKE_JOBS=${SRS_FORCE_MAKE_JOBS}"
\$(MAKE)\$(JOBS) -f ${SRS_OBJS}/Makefile srs
@bash objs/_srs_build_summary.sh
END

# generate all modules entry
for SRS_MODULE in ${SRS_MODULES[*]}; do
. $SRS_WORKDIR/auto/reset_module.sh && . $SRS_MODULE/config
Expand Down
7 changes: 7 additions & 0 deletions trunk/src/main/srs_main_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ srs_error_t do_main(int argc, char** argv, char** envp)
// TODO: Might fail if change working directory.
_srs_binary = argv[0];

// For sanitizer on macOS, to avoid the warning on startup.
#if defined(SRS_OSX) && defined(SRS_SANITIZER)
if (!getenv("MallocNanoZone")) {
fprintf(stderr, "Asan: Please setup the env MallocNanoZone=0 to disable the warning, see https://stackoverflow.com/a/70209891/17679565\n");
}
#endif

// Initialize global and thread-local variables.
if ((err = srs_global_initialize()) != srs_success) {
return srs_error_wrap(err, "global init");
Expand Down

0 comments on commit 7bdb727

Please sign in to comment.