Skip to content

Commit

Permalink
Make extended timeout duration an env
Browse files Browse the repository at this point in the history
  • Loading branch information
CouleeApps committed Oct 5, 2024
1 parent 3189264 commit 9581892
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ x-decompiler:
- backend_net
command: [
"--timeout", "${DECOMPILER_TIMEOUT:-120}",
"--extended-timeout", "${DECOMPILER_EXTENDED_TIMEOUT:-900}",
"--mem-limit-hard", "${DECOMPILER_MEM_LIMIT_HARD:-10000000000}",
"--mem-limit-soft", "${DECOMPILER_MEM_LIMIT_SOFT:-10000000000}"
]
Expand Down Expand Up @@ -164,6 +165,7 @@ services:
target: retdec
command: [
"--timeout", "${DECOMPILER_TIMEOUT:-120}",
"--extended-timeout", "${DECOMPILER_EXTENDED_TIMEOUT:-900}",
# Do not specify hard limit #12
"--mem-limit-soft", "${DECOMPILER_MEM_LIMIT_SOFT:-10000000000}"
]
Expand Down
6 changes: 3 additions & 3 deletions explorer/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,16 +72,16 @@ def get_decompilations_url(self, obj):


class DecompilationRequestSerializer(serializers.ModelSerializer):
skip_timeout = serializers.SerializerMethodField()
extend_timeout = serializers.SerializerMethodField()
download_url = serializers.SerializerMethodField()
binary_id = serializers.SerializerMethodField()
completion_url = serializers.SerializerMethodField()

class Meta:
model = DecompilationRequest
fields = ['id', 'binary_id', 'decompiler', 'created', 'last_attempted', 'skip_timeout', 'download_url', 'completion_url']
fields = ['id', 'binary_id', 'decompiler', 'created', 'last_attempted', 'extend_timeout', 'download_url', 'completion_url']

def get_skip_timeout(self, obj):
def get_extend_timeout(self, obj):
return obj.binary.featured

def get_download_url(self, obj):
Expand Down
5 changes: 3 additions & 2 deletions runners/decompiler/runner_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def __init__(self) -> None:
parser = argparse.ArgumentParser(description='Launch a decompiler script')
parser.add_argument('script_name', help='Script to run')
parser.add_argument('--timeout', type=int, default=None, help='Maximum time to spend decompiling each file')
parser.add_argument('--extended-timeout', type=int, default=None, help='Extended timeout for featured samples')
parser.add_argument('--mem-limit-hard', type=int, default=resource.RLIM_INFINITY, help='Hard memory limit for decompiling each file')
parser.add_argument('--mem-limit-soft', type=int, default=resource.RLIM_INFINITY, help='Soft memory limit for decompiling each file')
parser.add_argument('--debug', action='store_true', help='Log extra debug output')
Expand Down Expand Up @@ -202,8 +203,8 @@ def decompile_source(self, req, args, compiled):
child_proc = shlex.join([sys.executable, args.script_name])

timeout = args.timeout
if req['skip_timeout']:
timeout = 3600 # Surely an hour is long enough
if req['extend_timeout']:
timeout = args.extended_timeout

bash_timeout = timeout + 10
bash_cmd = f'set -o monitor ; timeout -s 9 {bash_timeout} {child_proc} < /dev/stdin'
Expand Down

0 comments on commit 9581892

Please sign in to comment.