Skip to content

Segmentation fault Error when script exists #2

Description

@jamesliu668

When I run the python file below, it will throw following error after python exist:

Segmentation fault (core dumped)

Here is my source code:

# -*- coding: utf-8 -*-

import json
import sys

filter = None
defaction = 0
try:
    import seccomp
except ImportError:
    # pip3 install pyseccomp -i https://mirrors.aliyun.com/pypi/simple
    import pyseccomp as seccomp
finally:
    # respond with EPERM: operation not permitted so users can tell
    # they're being blocked from doing something
    defaction = seccomp.ERRNO(seccomp.errno.EPERM)
    filter = seccomp.SyscallFilter(seccomp.ERRNO(seccomp.errno.EPERM))

    # allow `write`ing to two already-opened files stdout and stderr
    filter.add_rule(
        seccomp.ALLOW, "write", seccomp.Arg(0, seccomp.EQ, sys.stdout.fileno())
    )
    filter.add_rule(
        seccomp.ALLOW, "write", seccomp.Arg(0, seccomp.EQ, sys.stderr.fileno())
    )

    # load the filter in the kernel
    filter.load()

from typing import Dict, Any
Args = Dict[str, Any]
def main(args:Args) -> dict:
    return {
        "result": args["input"] + args["input"]
    }

# decode and prepare input dict
inputs_obj = {'input': '1'}

# execute main function
output_obj = main(inputs_obj)

# convert output to json and print
output_json = json.dumps(output_obj, indent=4, ensure_ascii=False)
print(output_json)

My env is ubuntu 22, python3.10.

Thx

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions