Skip to content

Segfault on ppc64 w/ JIT & SEAlloc #762

@OPNA2608

Description

@OPNA2608

With JIT and the SELinux allocator enabled, trying to use a basic regex pattern in grep results gives a segfault in PCRE2 (tested 1.44 & 1.45) on big-endian 64-bit POWER:

puna on HC ~/Development/nixpkgs $ echo '.' | grep -P '^.$'
grep: program error
Aborted

Under GDB:

Program received signal SIGSEGV, Segmentation fault.
sljit_exec_offset (code=0x3ffff7bf0020) at src/../deps/sljit/sljit_src/allocator_src/sljitExecAllocatorCore.c:325
warning: 325    src/../deps/sljit/sljit_src/allocator_src/sljitExecAllocatorCore.c: No such file or directory
(gdb) bt -full
#0  sljit_exec_offset (code=0x3ffff7bf0020) at src/../deps/sljit/sljit_src/allocator_src/sljitExecAllocatorCore.c:325
No locals.
#1  0x00003ffff7f0100c in pcre2_jit_compile_8 (code=0x100621b0, options=1) at src/pcre2_jit_compile.c:13983
        re = 0x100621b0
        exec_memory = 0x3ffff7bf0020
        functions = 0xf8f5f071a41d97
        executable_allocator_is_working = -1
#2  0x0000000010013a1c in Pcompile (pattern=0x10061c60 "^.$\n\367\347\r\200", size=3, ignored=0, exact=false) at pcresearch.c:251
        e = 0
        ec = 100
        flags = 16
        patlim = 0x10061c63 "\n\367\347\r\200"
        pc = 0x10061d00
        gcontext = 0x10061d40
        ccontext = 0x10061980
        extra_options = 256
        re_storage = 0x0
        ERRBUFSIZ = ERRBUFSIZ
#3  0x000000001000e198 in main (argc=4, argv=0x3ffffffff5c8) at grep.c:2980
        keys = 0x10061c60 "^.$\n\367\347\r\200"
        keycc = 3
        keyalloc = 0
        matcher = 6
        opt = -1
        prev_optind = 2
        last_recursive = 0
        default_context = -1
        fp = 0x3ffffffff540
        filename_option = 0
        possibly_tty = true
        tmp_stat = {st_dev = 19, st_ino = 4, st_nlink = 1, st_mode = 8594, st_uid = 1000, st_gid = 1000, __pad2 = 0, st_rdev = 34817, 
          st_size = 0, st_blksize = 1024, st_blocks = 0, st_atim = {tv_sec = 1752222536, tv_nsec = 468974401}, st_mtim = {
            tv_sec = 1752222536, tv_nsec = 468974401}, st_ctim = {tv_sec = 1752033965, tv_nsec = 468974401}, __glibc_reserved4 = 0, 
          __glibc_reserved5 = 0, __glibc_reserved6 = 0}
        eolbytes = "\000\000"
        match_size = 5
        num_operands = 0
        psize = 0
        files = 0x0
        status = false

Disabling the SELinux allocator fixes the segfault. As does disabling JIT, obviously.

Metadata

Metadata

Assignees

No one assigned

    Labels

    JITRelating to the JIT feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions