rizinorg / rz-pipe

Access rizin via pipe from any programming language!
33 stars 11 forks source link

timeout_callback signal.signal(signal.SIGALRM, callback) AttributeError: module 'signal' has no attribute 'SIGALRM' #49

Closed XVilka closed 1 year ago

XVilka commented 1 year ago

@wargio looks like recent rz-pipe changes broke the CI:

[XX] C:\projects\rizin\test\db\cmd\cmd_pipe rzpipe load project
ANSICON=1 RZ_NOPLUGINS=1 C:\projects\rizin\rizin-vs2022_64-v0.6.0\bin\rizin.exe -escr.utf8=0 -escr.color=0 -escr.interactive=0 -eflirt.sigdb.load.system=false -eflirt.sigdb.load.home=false -N -Qc '%q `env~?^ASAN_LD_PRELOAD=`
%+ env LD_PRELOAD=`env ASAN_LD_PRELOAD`
!python3 -c 'import rzpipe;rz=rzpipe.open("--");rz.cmd("Po bins/other/ls.rzdb");print(rz.cmd("%v custom_main"))'
' --
-- stdout
--- expected
+++ actual
@@ -1,2 +1,0 @@
-0x4070
-
-- stderr
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python38-x64\lib\site-packages\rzpipe\open_base.py", line 266, in cmd
    with timeout_callback(
  File "C:\Python38-x64\lib\contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "C:\Python38-x64\lib\site-packages\rzpipe\open_base.py", line 86, in timeout_callback
    signal.signal(signal.SIGALRM, callback)
AttributeError: module 'signal' has no attribute 'SIGALRM'
[XX] C:\projects\rizin\test\db\cmd\cmd_pipe rzpipe.py - shared memory (shm://)
ANSICON=1 RZ_NOPLUGINS=1 C:\projects\rizin\rizin-vs2022_64-v0.6.0\bin\rizin.exe -escr.utf8=0 -escr.color=0 -escr.interactive=0 -eflirt.sigdb.load.system=false -eflirt.sigdb.load.home=false -N -Qc '%q `env~?^ASAN_LD_PRELOAD=`
%+ env LD_PRELOAD=`env ASAN_LD_PRELOAD`
#!pipe python3 scripts/shared_memory.py
' 'bins/elf/_Exit (42)'
-- stdout
--- expected
+++ actual
@@ -3,83 +3,3 @@
 -------------
 Shared buffer size 0x360c
 -------------
-{'arch': 'x86', 'baddr': 134512640, 'binsz': 13073, 'bintype': 'elf', 'bits': 32, 'class': 'ELF32', 'compiler': 'GCC: (GNU) 9.2.1 20190827 (Red Hat 9.2.1-1)', 'endian': 'LE', 'intrp': '/lib/ld-linux.so.2', 'laddr': 0, 'lang': 'c++', 'machine': 'Intel 80386', 'maxopsz': 16, 'minopsz': 1, 'os': 'linux', 'pcalign': 0, 'relro': 'partial', 'rpath': 'NONE', 'subsys': 'linux', 'stripped': False, 'crypto': False, 'havecode': True, 'va': True, 'sanitiz': False, 'static': False, 'linenum': True, 'lsyms': True, 'canary': False, 'PIE': False, 'RELROCS': True, 'NX': True}
-- offset -   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF
-0x08049020  5589 e583 ec08 83ec 0c6a 2ae8 e0ff ffff  U........j*.....
-
-0x08049020    1 16           entry0
-0x08049010    1 6            sym.imp._Exit
-
-            ;-- section..text:
-            ;-- .text:
-            ;-- _start():
-/ entry0 ();
-|           0x08049020      push  ebp                                  ; [09] -r-x section size 16 named .text
-|           0x08049021      mov   ebp, esp
-|           0x08049023      sub   esp, 8
-|           0x08049026      sub   esp, 0xc
-|           0x08049029      push  0x2a                                 ; '*' ; 42 ; int status
-\           0x0804902b      call  sym.imp._Exit                        ; void _Exit(int status)
-
-Copying bins/pe/winver.exe...
-Copied bins/pe/winver.exe succesfully
--------------
-Shared buffer size 0x400
--------------
-{'arch': 'x86', 'baddr': 4194304, 'binsz': 1024, 'bintype': 'pe', 'bits': 32, 'retguard': False, 'class': 'PE32', 'cmp.csum': '0x00005082', 'compiled': 'Thu Jan  1 00:00:00 1970 UTC', 'endian': 'LE', 'hdr.csum': '0x00000000', 'laddr': 0, 'lang': 'c', 'machine': 'i386', 'maxopsz': 16, 'minopsz': 1, 'os': 'windows', 'overlay': False, 'cc': 'cdecl', 'pcalign': 0, 'signed': False, 'subsys': 'Windows CUI', 'stripped': False, 'crypto': False, 'havecode': True, 'va': True, 'sanitiz': False, 'static': False, 'linenum': False, 'lsyms': False, 'canary': False, 'PIE': False, 'RELROCS': False, 'NX': False}
-- offset -   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF
-0x00401000  6880 1040 00ff 15b4 1140 00ff 3590 1040  h..@.....@..5..@
-
-0x00401000    1 58           entry0
-
-            ;-- section.sect_0:
-/ entry0 ();
-|           0x00401000      push  0x401080                             ; LPOSVERSIONINFOA lpVersionInformation ; [00] -rwx section size 4096 named sect_0
-|           0x00401005      call  dword [sym.imp.kernel32.dll_GetVersionExA] ; 0x4011b4 ; BOOL GetVersionExA(LPOSVERSIONINFOA lpVersionInformation)
-|           0x0040100b      push  dword [0x401090]
-|           0x00401011      push  dword [0x40108c]
-|           0x00401017      push  dword [0x401088]
-|           0x0040101d      push  dword [0x401084]
-|           0x00401023      push  str.a_PE_overriding_OS_values:_OS_Ver__i._i._i_PlatformID__i ; 0x40103c ; " * a PE overriding OS values: OS Ver %i.%i.%i PlatformID %i\n\n" ; const char *format
-|           0x00401028      call  dword [sym.imp.msvcrt.dll_printf]    ; 0x4011bc ; int printf(const char *format)
-|           0x0040102e      add   esp, 0x10
-|           0x00401031      nop
-|           0x00401032      push  0                                    ; UINT uExitCode
-\           0x00401034      call  dword [sym.imp.kernel32.dll_ExitProcess] ; 0x4011b0 ; VOID ExitProcess(UINT uExitCode)
-
-Copying bins/mach0/mach0_2-x86_64...
-Copied bins/mach0/mach0_2-x86_64 succesfully
--------------
-Shared buffer size 0x10e8
--------------
-{'arch': 'x86', 'baddr': 4294967296, 'binsz': 4328, 'bintype': 'mach0', 'bits': 64, 'class': 'MACH064', 'endian': 'LE', 'intrp': '/usr/lib/dyld', 'laddr': 0, 'lang': 'c', 'machine': 'x86 64 all', 'maxopsz': 16, 'minopsz': 1, 'os': 'macos', 'pcalign': 0, 'subsys': 'darwin', 'stripped': False, 'crypto': False, 'havecode': True, 'va': True, 'sanitiz': False, 'static': False, 'linenum': False, 'lsyms': False, 'canary': False, 'PIE': True, 'RELROCS': False, 'NX': False}
-- offset -    0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF
-0x100000f70  5548 89e5 4883 ec10 c745 fc00 0000 0089  UH..H....E......
-
-0x100000f70    1 36           entry0
-0x100000f40    1 45           sym._foo
-0x100000ef0    4 65           sym._bar
-0x1000001d5    1 171          fcn.1000001d5
-0x1000002e0   13 3088 -> 3110 fcn.1000002e0
-
-            ;-- main:
-            ;-- _main:
-            ;-- func.100000f70:
-/ entry0 (int64_t arg1, int64_t arg2);
-|           ; arg int64_t arg1 @ rdi
-|           ; arg int64_t arg2 @ rsi
-|           ; var int64_t var_18h @ stack - 0x18
-|           ; var int64_t var_10h @ stack - 0x10
-|           ; var int64_t var_ch @ stack - 0xc
-|           0x100000f70      push  rbp
-|           0x100000f71      mov   rbp, rsp
-|           0x100000f74      sub   rsp, 0x10
-|           0x100000f78      mov   dword [var_ch], 0
-|           0x100000f7f      mov   dword [var_10h], edi                ; arg1
-|           0x100000f82      mov   qword [var_18h], rsi                ; arg2
-|           0x100000f86      mov   edi, dword [var_10h]                ; int64_t arg1
-|           0x100000f89      call  sym._foo
-|           0x100000f8e      add   rsp, 0x10
-|           0x100000f92      pop   rbp
-\           0x100000f93      ret
-
-- stderr
Traceback (most recent call last):
  File "scripts/shared_memory.py", line 22, in <module>
    rzp.cmd("e scr.color=0")
  File "C:\Python38-x64\lib\site-packages\rzpipe\open_base.py", line 266, in cmd
    with timeout_callback(
  File "C:\Python38-x64\lib\contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "C:\Python38-x64\lib\site-packages\rzpipe\open_base.py", line 86, in timeout_callback
    signal.signal(signal.SIGALRM, callback)
AttributeError: module 'signal' has no attribute 'SIGALRM'
[XX] C:\projects\rizin\test\db\cmd\cmd_pipe rzpipe.py
ANSICON=1 RZ_NOPLUGINS=1 C:\projects\rizin\rizin-vs2022_64-v0.6.0\bin\rizin.exe -escr.utf8=0 -escr.color=0 -escr.interactive=0 -eflirt.sigdb.load.system=false -eflirt.sigdb.load.home=false -N -Qc '%q `env~?^ASAN_LD_PRELOAD=`
%+ env LD_PRELOAD=`env ASAN_LD_PRELOAD`
#!pipe python3 scripts/get-funcs.py
' 'bins/elf/_Exit (42)'
-- stdout
--- expected
+++ actual
@@ -1,17 +1,0 @@
-
-Function names:
-entry0
-sym.imp._Exit
-
-Disassembly of entry0:
-            ;-- section..text:
-            ;-- .text:
-            ;-- _start():
-/ entry0 ();
-|           0x08049020      push  ebp                                  ; [09] -r-x section size 16 named .text
-|           0x08049021      mov   ebp, esp
-|           0x08049023      sub   esp, 8
-|           0x08049026      sub   esp, 0xc
-|           0x08049029      push  0x2a                                 ; '*' ; 42
-\           0x0804902b      call  sym.imp._Exit                        ; void _Exit(int status)
-
-- stderr
Traceback (most recent call last):
  File "scripts/get-funcs.py", line 4, in <module>
    rzp.cmd("aa")
  File "C:\Python38-x64\lib\site-packages\rzpipe\open_base.py", line 266, in cmd
    with timeout_callback(
  File "C:\Python38-x64\lib\contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "C:\Python38-x64\lib\site-packages\rzpipe\open_base.py", line 86, in timeout_callback
    signal.signal(signal.SIGALRM, callback)
AttributeError: module 'signal' has no attribute 'SIGALRM'

Originally posted by @XVilka in https://github.com/rizinorg/rizin/issues/3527#issuecomment-1562095804

XVilka commented 1 year ago

Should use this:

@arieltorti