Skip to contentSkip to conversation

Bug in Test code

DISCUSSION sameeruddin shaik 3 participants 5 messages Apr 11, 2021 – Apr 14, 2021

lore
Share & tools
lore
#0 lore raw

hi,

Test: tracing options ...FAILED
    1. tracefs-utest.c:746  - check_options_mask_empty(all)
    2. tracefs-utest.c:747  - check_options_mask_empty(enabled)
  Test: custom system directory ...FAILED
    1. tracefs-utest.c:746  - check_options_mask_empty(all)
    2. tracefs-utest.c:747  - check_options_mask_empty(enabled)
  Test: ftrace marker ...trace-utest: ../nptl/pthread_mutex_lock.c:81: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed. Aborted (core dumped)

Above tests are failing for me, what about you guys?

Do i have to give any command line options when running the test ?

I ran test like below

-----------------------

#./trace-utest

-----------------------

--sameer.

#1 lore raw
Quoted 17 lines · On Mon, 12 Apr 2021 06:43:44 +0530 sameeruddin shaik…

hi,

Test: tracing options ...FAILED
    1. tracefs-utest.c:746  - check_options_mask_empty(all)
    2. tracefs-utest.c:747  - check_options_mask_empty(enabled)
  Test: custom system directory ...FAILED
    1. tracefs-utest.c:746  - check_options_mask_empty(all)
    2. tracefs-utest.c:747  - check_options_mask_empty(enabled)
  Test: ftrace marker ...trace-utest: ../nptl/pthread_mutex_lock.c:81:
__pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed. Aborted (core dumped)

Above tests are failing for me, what about you guys?

Do i have to give any command line options when running the test ?

Quoted 8 lines

I ran test like below

-----------------------

#./trace-utest

-----------------------

Hi Sameer,

Thanks for the report. Yes, it is a bug in the tests. We did a last minute change to have the options bitmask be stored in the instance and it is immutable, but did not update the tests. The below patch should fix it for you. Let us know if it does.

Thanks!

-- Steve

utest/tracefs-utest.c +4 -6
index 1f48e6f..3407202 100644
@@ -679,7 +679,7 @@ out:
 	return ret;
 }
 
-static bool check_options_mask_empty(struct tracefs_options_mask *mask)
+static bool check_options_mask_empty(const struct tracefs_options_mask *mask)
 {
 	int i;
 
@@ -692,8 +692,9 @@ static bool check_options_mask_empty(struct tracefs_options_mask *mask)
 
 static void test_instance_tracing_options(struct tracefs_instance *instance)
 {
-	struct tracefs_options_mask *enabled;
-	struct tracefs_options_mask *all, *all_copy;
+	const struct tracefs_options_mask *enabled;
+	const struct tracefs_options_mask *all_copy;
+	const struct tracefs_options_mask *all;
 	enum tracefs_option_id i = 1;
 	char file[PATH_MAX];
 	const char *name;
@@ -745,9 +746,6 @@ static void test_instance_tracing_options(struct tracefs_instance *instance)
 	}
 	CU_TEST(check_options_mask_empty(all));
 	CU_TEST(check_options_mask_empty(enabled));
-
-	free(all);
-	free(enabled);
 }
 
 static void test_tracing_options(void)
#2 lore raw
Quoted 65 lines · Steven Rostedt
Quoted 17 lines · On Mon, 12 Apr 2021 06:43:44 +0530 sameeruddin shaik…

hi,

Test: tracing options ...FAILED
    1. tracefs-utest.c:746  - check_options_mask_empty(all)
    2. tracefs-utest.c:747  - check_options_mask_empty(enabled)
  Test: custom system directory ...FAILED
    1. tracefs-utest.c:746  - check_options_mask_empty(all)
    2. tracefs-utest.c:747  - check_options_mask_empty(enabled)
  Test: ftrace marker ...trace-utest: ../nptl/pthread_mutex_lock.c:81:
__pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed. Aborted (core dumped)

Above tests are failing for me, what about you guys?

Do i have to give any command line options when running the test ?

Quoted 8 lines

I ran test like below

-----------------------

#./trace-utest

-----------------------

Hi Sameer,

Thanks for the report. Yes, it is a bug in the tests. We did a last minute change to have the options bitmask be stored in the instance and it is immutable, but did not update the tests. The below patch should fix it for you. Let us know if it does.

Thanks!

-- Steve

utest/tracefs-utest.c +4 -3
index 1f48e6f..3407202 100644
@@ -679,7 +679,7 @@ out:
  	return ret;
  }
 
-static bool check_options_mask_empty(struct tracefs_options_mask *mask)
+static bool check_options_mask_empty(const struct tracefs_options_mask *mask)
  {
  	int i;
 
@@ -692,8 +692,9 @@ static bool check_options_mask_empty(struct tracefs_options_mask *mask)
 
  static void test_instance_tracing_options(struct tracefs_instance *instance)
  {
-	struct tracefs_options_mask *enabled;
-	struct tracefs_options_mask *all, *all_copy;
+	const struct tracefs_options_mask *enabled;
+	const struct tracefs_options_mask *all_copy;
+	const struct tracefs_options_mask *all;
  	enum tracefs_option_id i = 1;
  	char file[PATH_MAX];
  	const char *name;

utest/tracefs-utest.c static void test_instance_tracing_options(struct tracefs_instance *instance) · line 751

Quoted 9 lines
utest/tracefs-utest.c +0 -3
@@ -745,9 +746,6 @@ static void test_instance_tracing_options(struct tracefs_instance *instance)
  	}
  	CU_TEST(check_options_mask_empty(all));
  	CU_TEST(check_options_mask_empty(enabled));
-
-	free(all);
-	free(enabled);
  }
 
  static void test_tracing_options(void)

No steve it didn't resolved the issue,

root@sameeraaron-Lenovo-Z50-70:/home/sameeraaron/hobbies/libtracefs/utest# ./trace-utest

     CUnit - A unit testing framework for C - Version 2.1-3
     http://cunit.sourceforge.net/

*** Error in `./trace-utest': malloc(): memory corruption: 0x0000000001251670 *** ======= Backtrace: ========= /lib/x86_64-linux-gnu/libc.so.6(+0x777f5)[0x7f7f8171f7f5] /lib/x86_64-linux-gnu/libc.so.6(+0x8215e)[0x7f7f8172a15e] /lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x54)[0x7f7f8172c1d4] /usr/local/lib64/libtraceevent.so.1(tep_register_print_string+0x1f)[0x7f7f81ea322c] /usr/local/lib64/libtraceevent.so.1(tep_parse_printk_formats+0x10c)[0x7f7f81ea34cf] ./trace-utest[0x40bf2e]
./trace-utest[0x40bf9d]
./trace-utest[0x40c160] ./trace-utest(tracefs_local_events_system+0x48)[0x40c1c0] ./trace-utest[0x408c19] /usr/lib/x86_64-linux-gnu/libcunit.so.1(+0x3e7e)[0x7f7f81a75e7e] /usr/lib/x86_64-linux-gnu/libcunit.so.1(CU_run_all_tests+0x6e)[0x7f7f81a763be] ./trace-utest(main+0x10b)[0x403501] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f7f816c8840] ./trace-utest(_start+0x29)[0x4032a9]

--sameer.

#3 lore raw

Hi Sameer,

Quoted 76 lines · sameeruddin shaik
Quoted 73 lines · Steven Rostedt
Quoted 17 lines · On Mon, 12 Apr 2021 06:43:44 +0530 sameeruddin shaik…

hi,

Test: tracing options ...FAILED
1. tracefs-utest.c:746 - check_options_mask_empty(all)
2. tracefs-utest.c:747 - check_options_mask_empty(enabled)
Test: custom system directory ...FAILED
1. tracefs-utest.c:746 - check_options_mask_empty(all)
2. tracefs-utest.c:747 - check_options_mask_empty(enabled)
Test: ftrace marker ...trace-utest: ../nptl/pthread_mutex_lock.c:81:
__pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed. Aborted (core dumped)

Above tests are failing for me, what about you guys?

Do i have to give any command line options when running the test ?

Quoted 8 lines

I ran test like below

-----------------------

#./trace-utest

-----------------------

Hi Sameer,

Thanks for the report. Yes, it is a bug in the tests. We did a last minute change to have the options bitmask be stored in the instance and it is immutable, but did not update the tests. The below patch should fix it for you. Let us know if it does.

Thanks!

-- Steve

utest/tracefs-utest.c +4 -6
index 1f48e6f..3407202 100644
@@ -679,7 +679,7 @@ out:
      return ret;
  }
 
-static bool check_options_mask_empty(struct tracefs_options_mask *mask)
+static bool check_options_mask_empty(const struct tracefs_options_mask *mask)
  {
      int i;
 
@@ -692,8 +692,9 @@ static bool check_options_mask_empty(struct tracefs_options_mask *mask)
 
  static void test_instance_tracing_options(struct tracefs_instance *instance)
  {
-     struct tracefs_options_mask *enabled;
-     struct tracefs_options_mask *all, *all_copy;
+     const struct tracefs_options_mask *enabled;
+     const struct tracefs_options_mask *all_copy;
+     const struct tracefs_options_mask *all;
      enum tracefs_option_id i = 1;
      char file[PATH_MAX];
      const char *name;
@@ -745,9 +746,6 @@ static void test_instance_tracing_options(struct tracefs_instance *instance)
      }
      CU_TEST(check_options_mask_empty(all));
      CU_TEST(check_options_mask_empty(enabled));
-
-     free(all);
-     free(enabled);
  }
 
Quoted 3 lines

utest/tracefs-utest.c static void test_instance_tracing_options(struct tracefs_instance *instance) · line 751

Quoted 1 line
utest/tracefs-utest.c +0 -0
  static void test_tracing_options(void)

No steve it didn't resolved the issue,

Thanks for running the unit tests and testing the latest release. Indeed, there is a bug in that code that leads to a memory corruption. And we neglected the unit tests, did not align with the latest changes in the APIs.
Please, check if the patch set that I just sent fixes this in your
environment: "[PATCH 0/3] Fix unit tests and APIs for loading saved mappings".

[ ... ]

--
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center

#4 lore raw

hi Tzvetomir,
Its worked
--sameer.

Quoted 99 lines · Tzvetomir Stoyanov

Hi Sameer,

Quoted 76 lines · sameeruddin shaik
Quoted 73 lines · Steven Rostedt
Quoted 17 lines · On Mon, 12 Apr 2021 06:43:44 +0530 sameeruddin shaik…

hi,

Test: tracing options ...FAILED
1. tracefs-utest.c:746 - check_options_mask_empty(all)
2. tracefs-utest.c:747 - check_options_mask_empty(enabled)
Test: custom system directory ...FAILED
1. tracefs-utest.c:746 - check_options_mask_empty(all)
2. tracefs-utest.c:747 - check_options_mask_empty(enabled)
Test: ftrace marker ...trace-utest: ../nptl/pthread_mutex_lock.c:81:
__pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed. Aborted (core dumped)

Above tests are failing for me, what about you guys?

Do i have to give any command line options when running the test ?

Quoted 8 lines

I ran test like below

-----------------------

#./trace-utest

-----------------------

Hi Sameer,

Thanks for the report. Yes, it is a bug in the tests. We did a last minute change to have the options bitmask be stored in the instance and it is immutable, but did not update the tests. The below patch should fix it for you. Let us know if it does.

Thanks!

-- Steve

utest/tracefs-utest.c +4 -6
index 1f48e6f..3407202 100644
@@ -679,7 +679,7 @@ out:
      return ret;
  }
 
-static bool check_options_mask_empty(struct tracefs_options_mask *mask)
+static bool check_options_mask_empty(const struct tracefs_options_mask *mask)
  {
      int i;
 
@@ -692,8 +692,9 @@ static bool check_options_mask_empty(struct tracefs_options_mask *mask)
 
  static void test_instance_tracing_options(struct tracefs_instance *instance)
  {
-     struct tracefs_options_mask *enabled;
-     struct tracefs_options_mask *all, *all_copy;
+     const struct tracefs_options_mask *enabled;
+     const struct tracefs_options_mask *all_copy;
+     const struct tracefs_options_mask *all;
      enum tracefs_option_id i = 1;
      char file[PATH_MAX];
      const char *name;
@@ -745,9 +746,6 @@ static void test_instance_tracing_options(struct tracefs_instance *instance)
      }
      CU_TEST(check_options_mask_empty(all));
      CU_TEST(check_options_mask_empty(enabled));
-
-     free(all);
-     free(enabled);
  }
 
Quoted 3 lines

utest/tracefs-utest.c static void test_instance_tracing_options(struct tracefs_instance *instance) · line 751

Quoted 1 line
utest/tracefs-utest.c +0 -0
  static void test_tracing_options(void)

No steve it didn't resolved the issue,

Thanks for running the unit tests and testing the latest release. Indeed, there is a bug in that code that leads to a memory corruption. And we neglected the unit tests, did not align with the latest changes in the APIs.
Please, check if the patch set that I just sent fixes this in your
environment: "[PATCH 0/3] Fix unit tests and APIs for loading saved mappings".

[ ... ]

--
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center