Project

General

Profile

Bug #1166

Updated by Jonathan Rajotte Julien almost 6 years ago

Hi 

 If lttng-sessiond terminates unexpectedly after truncating the metadata file from --shm-path path (when doing metadata regenerate), afterwards when trying to recover the trace buffers using lttng-crash <- it Bus error (core dumped). This translates to: 

 <pre> 
 $ lttng create s1 --shm-path=/tmp/test-lttng 
 $ lttng enable-event -u -a -s s1 
 $ lttng start 
 $ <path>/lttng-tools/tests/utils/testapp/gen-ust-events/gen-ust-events 
 $ pkill -9 "lttng-" # 1 
 $ cp /dev/null /tmp/test/s1-*/ust/uid/1000/64-bit/metadata # 2 - 1 and 2 simulate sessiond crash immediately after ftruncate() during metadata regenerate 
 $ lttng-crash --viewer=babeltrace /tmp/test-lttng/ 

 </pre> 

 A possible fix is : 

 <pre> 
 --- 
  src/bin/lttng-crash/lttng-crash.c | 11 +++++++++-- 
  1 file changed, 9 insertions(+), 2 deletions(-) 

 diff --git a/src/bin/lttng-crash/lttng-crash.c b/src/bin/lttng-crash/lttng-crash.c 
 index ba28af9..0fb93fd 100644 
 --- a/src/bin/lttng-crash/lttng-crash.c 
 +++ b/src/bin/lttng-crash/lttng-crash.c 
 @@ -490,7 +490,8 @@ int check_magic(const uint8_t *magic) 
  } 
 
  static 
 -int get_crash_layout(struct lttng_crash_layout *layout, int fd) 
 +int get_crash_layout(struct lttng_crash_layout *layout, int fd, 
 + 	 const char *input_path, const char *input_file) 
  { 
 	 char *map; 
 	 int ret = 0, unmapret; 
 @@ -501,7 +502,13 @@ int get_crash_layout(struct lttng_crash_layout *layout, int fd) 
 	 const struct crash_abi_unknown *abi; 
 	 uint16_t endian; 
 	 enum lttng_crash_type layout_type; 
 + 	 struct stat sb; 
 
 + 	 fstat(fd, &sb); 
 + 	 if (sb.st_size <    RB_CRASH_DUMP_ABI_LEN) { 
 + 		 ERR("File truncated: %s/%s", input_path, input_file); 
 + 		 return -1; 
 + 	 } 
 	 map = mmap(NULL, RB_CRASH_DUMP_ABI_LEN, PROT_READ, MAP_PRIVATE, 
 		 fd, 0); 
 	 if (map == MAP_FAILED) { 
 @@ -830,7 +837,7 @@ int extract_file(int output_dir_fd, const char *output_file, 
 	 } 
 
 	 /* Query the crash ABI layout */ 
 - 	 ret = get_crash_layout(&layout, fd_src); 
 + 	 ret = get_crash_layout(&layout, fd_src, input_path, input_file); 
 	 if (ret) { 
 		 goto close_src; 
 	 } 
 --  
 1.9.1 
 </pre> 

Back