Skip to content

Commit

Permalink
Fix r2 -a tms320 - -qc "pd 1" segfault (via @Maijin)
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Feb 16, 2015
1 parent 33ba03e commit fe7b7c7
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libr/core/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,8 @@ static char *colorize_asm_string(RCore *core, RDisasmState *ds) {

scol1 = r_print_colorize_opcode (s1, ds->color_reg, ds->color_num); free(s1);
scol2 = r_print_colorize_opcode (s2, ds->color_reg, ds->color_num); free(s2);
if (!scol1) scol1 = strdup ("");
if (!scol2) scol1 = strdup ("");

This comment has been minimized.

Copy link
@XVilka

XVilka Feb 16, 2015

Contributor

Should it be "if (!scol2) scol2 = strdup ("");"? Or I'm missing something?


source = malloc (strlen(scol1) + strlen(scol2) + 2 + 1); // reuse source variable
sprintf (source, "%s||%s", scol1, scol2);
Expand Down

4 comments on commit fe7b7c7

@radare
Copy link
Collaborator Author

@radare radare commented on fe7b7c7 Feb 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 180d5b9

@XVilka
Copy link
Contributor

@XVilka XVilka commented on fe7b7c7 Feb 16, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error is still here:

┌─[ xvilka@xxlaptop ] [ 1:02:59 ] ~ 
└>r2 -e scr.color=false -a tms320 /bin/ls -qc "pd 1"
                ;-- entry0:
                0x004047f5    31ed         || MIN AR6, AR5
┌─[ xvilka@xxlaptop ] [ 1:02:59 ] ~ 
└>r2 -a tms320 /bin/ls -qc "pd 1"
Segmentation fault
┌─[ xvilka@xxlaptop ] [ 1:02:59 ] ~ 
└>gdb r2
GNU gdb (Gentoo 7.8.2 vanilla) 7.8.2
Reading symbols from r2...Reading symbols from /usr/lib64/debug//usr/bin/radare2.debug...done.
done.
gdb$ run -a tms320 /bin/ls -qc "pd 1"
Starting program: /usr/bin/r2 -a tms320 /bin/ls -qc "pd 1"
warning: Could not load shared library symbols for linux-vdso.so.1.
Do you need "set solib-search-path" or "set sysroot"?
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
-----------------------------------------------------------------------------------------------------------------------[regs]
  RAX: 0x0000000000000000  RBX: 0x00007FFFF76B4900  RBP: 0x00007FFFFFFFBE30  RSP: 0x00007FFFFFFFBDD8  o d I t S z A p C 
  RDI: 0x0000000000000000  RSI: 0x00007FFFF433BCC8  RDX: 0x00000000006CC800  RCX: 0x0000000000000000  RIP: 0x00007FFFF402856A
  R8 : 0x00000000FFFFFFFF  R9 : 0x00000000006CC810  R10: 0x313B353B38335B1B  R11: 0x00007FFFF4101BC0  R12: 0x0000000000402950
  R13: 0x0000000000000000  R14: 0x0000000000000000  R15: 0x0000000000000000
  CS: 0033  DS: 0000  ES: 0000  FS: 0000  GS: 0000  SS: 002B                
-----------------------------------------------------------------------------------------------------------------------[code]
=> 0x7ffff402856a <strlen+42>:  movdqu (%rax),%xmm12
   0x7ffff402856f <strlen+47>:  pcmpeqb %xmm8,%xmm12
   0x7ffff4028574 <strlen+52>:  pmovmskb %xmm12,%edx
   0x7ffff4028579 <strlen+57>:  test   %edx,%edx
   0x7ffff402857b <strlen+59>:  je     0x7ffff4028581 <strlen+65>
   0x7ffff402857d <strlen+61>:  bsf    %edx,%eax
   0x7ffff4028580 <strlen+64>:  retq   
   0x7ffff4028581 <strlen+65>:  and    $0xfffffffffffffff0,%rax
-----------------------------------------------------------------------------------------------------------------------------
strlen () at ../sysdeps/x86_64/strlen.S:106
106     movdqu  (%rax), %xmm12
gdb$ bt
#0  strlen () at ../sysdeps/x86_64/strlen.S:106
#1  0x00007ffff7b99760 in colorize_asm_string (core=0x6075c0 <r>, ds=0xa21cb0) at disasm.c:374
#2  0x00007ffff7b9980f in handle_build_op_str (core=0x6075c0 <r>, ds=0xa21cb0) at disasm.c:385
#3  0x00007ffff7b9f048 in r_core_print_disasm (p=0x66c3b0, core=0x6075c0 <r>, addr=0x4047f5, buf=0x6cc680 "1\355I\211\321^H\211\342H\203\344\360PTI\307\300\240 
A", len=0xa, l=0x1, invbreak=0x0, cbytes=0x0) at disasm.c:1858
#4  0x00007ffff7b581b1 in cmd_print (data=0x6075c0 <r>, input=0x6ccb61 "d 1") at cmd_print.c:1591
#5  0x00007ffff7b87d3b in r_cmd_call (cmd=0x6a97e0, input=0x6ccb60 "pd 1") at cmd_api.c:179
#6  0x00007ffff7b6631b in r_core_cmd_subst_i (core=0x6075c0 <r>, cmd=0x6ccb60 "pd 1") at cmd.c:1366
#7  0x00007ffff7b6477a in r_core_cmd_subst (core=0x6075c0 <r>, cmd=0x6ccb60 "pd 1") at cmd.c:919
#8  0x00007ffff7b66ffd in r_core_cmd (core=0x6075c0 <r>, cstr=0x7fffffffdeb3 "pd 1", log=0x0) at cmd.c:1572
#9  0x00007ffff7b67624 in r_core_cmd0 (user=0x6075c0 <r>, cmd=0x7fffffffdeb3 "pd 1") at cmd.c:1695
#10 0x0000000000404d50 in main (argc=0x6, argv=0x7fffffffdb28, envp=0x7fffffffdb60) at radare2.c:669
gdb$ 

@radare
Copy link
Collaborator Author

@radare radare commented on fe7b7c7 Feb 17, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@XVilka
Copy link
Contributor

@XVilka XVilka commented on fe7b7c7 Feb 17, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@radare - system was ok, I was debugging the wrong version of radare2 (older, without strdup) with the new sources (dwarf). All OK now.

Please sign in to comment.