build-android/enable_address_sanitizer.patch
author Krista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 29 May 2019 09:59:00 +0200
branchsync
changeset 3762 55501092d6e3
parent 3742 37d915105396
permissions -rw-r--r--
Yeah, so static local variables are dangerous with multiple threads. (This has apparently been in since revision 0, so we should probably look out for other similar assumptions in the code.
     1 diff --git a/build-android/jni/Android.mk b/build-android/jni/Android.mk
     2 --- a/build-android/jni/Android.mk
     3 +++ b/build-android/jni/Android.mk
     4 @@ -14,7 +14,9 @@
     5  
     6  LOCAL_MODULE    := pEpEngine
     7  LOCAL_CFLAGS    += -std=c99
     8 -
     9 +#LOCAL_CFLAGS    += -fsanitize=address -fno-omit-frame-pointer
    10 +#LOCAL_LDFLAGS   += -fsanitize=address
    11 +#LOCAL_ARM_MODE := arm
    12  # from http://www.sqlite.org/android/finfo?name=jni/sqlite/Android.mk 
    13  #      http://www.sqlite.org/android/artifact/e8ed354b3e58c835
    14  
    15 @@ -28,6 +30,7 @@
    16                      $(GPGME_INCLUDE_PATH) \
    17                      $(LIBETPAN_PATH)/include
    18  LOCAL_C_INCLUDES += $(GPGBUILD)/$(TARGET_ARCH_ABI)/app_opt/include
    19 +LOCAL_C_INCLUDES += /home/huss/src/test/sequoia/openpgp-ffi/include
    20  
    21  $(shell sh $(LOCAL_PATH)/../takeOutHeaderFiles.sh $(LOCAL_PATH)../../)
    22  LOCAL_EXPORT_C_INCLUDES += $(LOCAL_PATH)../include
    23 @@ -38,5 +41,6 @@
    24  ASN1_SRC_FILES := $(wildcard $(LOCAL_PATH)/../../asn.1/*.c)
    25  LOCAL_SRC_FILES := $(ENGINE_SRC_FILES:%=%)  $(ASN1_SRC_FILES:$(LOCAL_PATH)/%=%)
    26  
    27 +#LOCAL_ADDRESS_SANITIZER:=true
    28  
    29  include $(BUILD_STATIC_LIBRARY)
    30 diff --git a/src/pEpEngine.c b/src/pEpEngine.c
    31 --- a/src/pEpEngine.c
    32 +++ b/src/pEpEngine.c
    33 @@ -2015,7 +2015,7 @@
    34  // N.B. If testing (so NDEBUG not defined) but this message is spam,
    35  //      put -D_PEP_SERVICE_LOG_OFF into CFLAGS/CXXFLAGS     
    36  #if !defined(NDEBUG) && !defined(_PEP_SERVICE_LOG_OFF)
    37 -    fprintf(stdout, "\n*** %s %s %s %s\n", title, entity, description, comment);
    38 +    __android_log_print(ANDROID_LOG_DEBUG, "pEpEngine", " %s :: %s :: %s :: %s ", title, entity, description, comment);
    39      session->service_log = true;
    40  #endif
    41  
    42 diff --git a/sync/gen_dot.ysl2 b/sync/gen_dot.ysl2
    43 --- a/sync/gen_dot.ysl2
    44 +++ b/sync/gen_dot.ysl2
    45 @@ -9,7 +9,7 @@
    46      digraph finite_state_machine {
    47          rankdir=LR;
    48          node [shape = doublecircle];
    49 -        `apply "state[@end='1']" mode=end`;
    50 +        `apply "state[@timeout='off']" mode=end`;
    51          node [shape = circle];
    52  
    53          `` apply "state" mode=do
    54 diff --git a/sync/sync.fsm b/sync/sync.fsm
    55 --- a/sync/sync.fsm
    56 +++ b/sync/sync.fsm
    57 @@ -155,7 +155,7 @@
    58                  go HandshakingNewPhase2Second;
    59          }
    60  
    61 -        state HandshakingNewPhase1First {
    62 +        state HandshakingNewPhase1First timeout=300 {
    63              on Rollback if sameTransactionAndPartner {
    64                  do untrustThisKey;
    65                  go Sole;
    66 @@ -172,7 +172,7 @@
    67              }
    68          }
    69  
    70 -        state HandshakingNewPhase1Second {
    71 +        state HandshakingNewPhase1Second timeout=300 {
    72              on Rollback if sameTransactionAndPartner {
    73                  do untrustThisKey;
    74                  go Sole;
    75 @@ -189,7 +189,7 @@
    76              }
    77          }
    78  
    79 -        state HandshakingNewPhase2First {
    80 +        state HandshakingNewPhase2First timeout=300 {
    81              on Cancel {
    82                  send Rollback;
    83                  go Sole;
    84 @@ -208,7 +208,7 @@
    85              }
    86          }
    87  
    88 -        state HandshakingNewPhase2Second {
    89 +        state HandshakingNewPhase2Second timeout=300 {
    90              on Cancel {
    91                  send Rollback;
    92                  go Sole;