Fix ASAN build error 87/201587/1 accepted/tizen/unified/20190327.160533 submit/tizen/20190327.041330
authorShinwoo Kim <cinoo.kim@samsung.com>
Mon, 18 Mar 2019 04:05:53 +0000 (13:05 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Mon, 18 Mar 2019 04:16:09 +0000 (13:16 +0900)
There is a build error with following build option for ASAN.

$ gbs build -A armv7l --include-all
  --extra-packs asan-force-options,asan-build-env --define 'asan 1'

[Build Error]
multiple definition of `child_pid'

[How to Fix]
This occurs when –fno-common flag is added to compiler (which is default in
asan-force-options) some linking may fail with error like above.

The reason of the bug is that global is defined in more than one compilation
unit without extern or static. When using default –fcommon option global
variables with the same name are merged into the same variable without
signaling errors.

When -fno-common option is enabled all global variables are treated separately
as they supposed to be. It means that each global variable should be defined
only once. Otherwise means an error in source code and is reported at linking
stage. It must be fixed by modifying each declaration as static or merging
into an extern declaration and a definition in a single .c file.

Change-Id: If913d75c4b212f129e5535eb4f332e7721611215

tests/atk_test_util.h

index b2376d5..26462ed 100644 (file)
@@ -36,7 +36,7 @@
 #include <locale.h>
 #include "atk_suite.h"
 
-pid_t child_pid;
+static pid_t child_pid;
 
 void run_app (const char *file_name);
 AtspiAccessible *get_root_obj (const char *file_name);