Project

General

Profile

Actions

Defect #663

open

Segfault in u8 arithmetics on x86 (works on x86_64)

Added by Rochus Keller about 1 year ago. Updated about 1 year ago.

Status:
Confirmed
Priority:
Normal
Category:
-
Target version:
-
% Done:

0%


Description

Meanwhile I was able to track down the segfault to this statemement in glue_imp.c (attached):

glue_imp.c:145:          stream->pos.offset += rc;

pos.offset is declared as unsigned long long.

The segfault only happens on x86; when I run the app on x86_64, no segfault happens.

When I change the type of pos.offset to int, then line 145 works (i.e. it segfaults somewhere else).

The generated IR looks correct:

    loc    "/home/me/Entwicklung/Modules/EiGen/ecc/libc/libc/glue_imp.c", 145, 1
    mov    ptr $0, ptr [$fp + 8]
    mov    ptr [$fp - 12], ptr $0 + 20
    conv    u8 $0, s4 [$fp - 36]
    mov    ptr $1, ptr [$fp - 12]
    add    u8 $1, u8 [$1], u8 $0
    mov    ptr $0, ptr [$fp - 12]
    mov    u8 [$0], u8 $1

I added all cod files plus the amd32linux.obf required to compile and run the app as an attachment. If you need the source code, the most recent commit is on https://github.com/rochus-keller/Eigen; the test.c application is in the ecs/libc subdirectory with the corresponding BUSY file.


Files

glue_imp.c (15.2 KB) glue_imp.c Rochus Keller, 02 July 2024 19:10
all_required_cod_with_dbg_info.tar.gz (233 KB) all_required_cod_with_dbg_info.tar.gz Rochus Keller, 02 July 2024 19:10
Actions

Also available in: Atom PDF