Menu

#57 Crache on first run

v1.0_(example)
open
nobody
None
1
2024-09-23
2024-08-23
Anonymous
No

Hello!
I compile game from sources (current trunk)
Copy all needed files by Readme_Linux.txt
After run game craches.

I recompiled with debug symbols and run game from gdb.

Backtrace below:

Thread 1 "quake2xp" received signal SIGSEGV, Segmentation fault.
BuildSurfaceNeighbours (surf=0x5555c8a3f448) at ../renderer/r_model.c:1058
1058                                    surf->polys->neighbours[i] = tempEdge->poly[j];
(gdb) bt
#0  BuildSurfaceNeighbours (surf=0x5555c8a3f448) at ../renderer/r_model.c:1058
#1  0x0000555555637008 in Mod_LoadFaces (l=0x5555c741b7e0) at ../renderer/r_model.c:1458
#2  0x0000555555639287 in Mod_LoadBrushModel (mod=0x5555c2889f20 <mod_known>, buffer=0x5555c741b7a8) at ../renderer/r_model.c:2113
#3  0x0000555555633344 in Mod_ForName (name=0x7fffffffcd20 "maps/base2.bsp", crash=true) at ../renderer/r_model.c:555
#4  0x000055555563d2f7 in R_BeginRegistration (model=0x7fffffffcdc0 "base2") at ../renderer/r_model.c:2803
#5  0x0000555555596434 in CL_PrepRefresh () at ../client/cg_view.c:238
#6  0x00005555555a26a1 in CL_Precache_f () at ../client/cl_main.c:1192
#7  0x00005555555c466f in Cmd_ExecuteString (text=0x7fffffffceb0 "precache") at ../qcommon/cmd.c:855
#8  0x00005555555c3149 in Cbuf_Execute () at ../qcommon/cmd.c:225
#9  0x00005555555a388b in CL_RefreshInputs () at ../client/cl_main.c:1508
#10 0x00005555555a3cf7 in CL_Frame_Async (msec=2) at ../client/cl_main.c:1641
#11 0x00005555555a3fd7 in CL_Frame (msec=2) at ../client/cl_main.c:1774
#12 0x00005555555cca0f in Qcommon_Frame (msec=2) at ../qcommon/common.c:1902
#13 0x0000555555664416 in main (argc=7, argv=0x7fffffffd528) at ../linux/sys.c:462
1 Attachments

Discussion

  • Anonymous

    Anonymous - 2024-08-23

    screen on crache moment

     
  • Anonymous

    Anonymous - 2024-08-23
    $ md5sum *.pak
    1ec55a724dc3109fd50dde71ab581d70  pak0.pak
    42663ea709b7cd3eb9b634b36cfecb1a  pak1.pak
    c8217cc5557b672a87fc210c2347d98d  pak2.pak
    f5cdf71cecae9ffcd3c380a9a00a61bb  q2xp0.pak
    8be464743c5873cba5febf3733881abf  q2xpMaps.pak
    1f82807fbe63046e2be92a3134407625  q2xpMusic.pak
    5e6c3fd1f29003fbb4ff42f25af13309  q2xpTextures0.pak
    
     
  • Kirk Barnes

    Kirk Barnes - 2024-08-23

    Yes, at the moment the code crashes under Linux, I will fix it soon.

     
  • Egor

    Egor - 2024-08-24
    trunk $ svn diff
    Index: client/cg_screen.c
    ===================================================================
    --- client/cg_screen.c  (revision 1518)
    +++ client/cg_screen.c  (working copy)
    @@ -324,7 +324,7 @@
                    < CMD_BACKUP - 1)
                    return;
    
    -       Draw_ScaledPic(scr_vrect.x, scr_vrect.y, ui_fontScale->value, ui_fontScale->value, 0, i_net, "null");
    +       Draw_ScaledPic(scr_vrect.x, scr_vrect.y, ui_fontScale->value, ui_fontScale->value, 0, i_net, NULL);
     }
    
     /*
    @@ -564,10 +564,10 @@
             ** all other models are sorted by model then skin
             */
            if (a->model == b->model) {
    -               return ((int)a->skin - (int)b->skin);
    +               return ((long)a->skin - (long)b->skin);
            }
            else {
    -               return ((int)a->model - (int)b->model);
    +               return ((long)a->model - (long)b->model);
            }
     }
    
    Index: game/q_shared.c
    ===================================================================
    --- game/q_shared.c     (revision 1518)
    +++ game/q_shared.c     (working copy)
    @@ -39,7 +39,7 @@
      =================
     */
    
    -inline char b_chrt(char sym)
    +char b_chrt(char sym)
     {
            if ((sym > 0x40) && (sym < 0x5b)) return sym + 0x20;            // "a" - "A"
            if (sym == 0x5c) return 0x2f;                                           // "/" - "\"
    Index: linux/input.c
    ===================================================================
    --- linux/input.c       (revision 1518)
    +++ linux/input.c       (working copy)
    @@ -63,7 +63,7 @@
     static cvar_t *m_filter;
     static cvar_t *exponential_speedup;
    
    -inline void
    +void
     Do_Key_Event (int key, bool down)
     {
            Key_Event(key, down, Sys_Milliseconds());
    Index: renderer/r_math.c
    ===================================================================
    --- renderer/r_math.c   (revision 1518)
    +++ renderer/r_math.c   (working copy)
    @@ -56,7 +56,7 @@
            }
     }
     #else
    -__inline void Q_sincos (float a, float *s, float *c) {
    +void Q_sincos (float a, float *s, float *c) {
            *s = (float)sin (a);
            *c = (float)cos (a);
     }
    Index: renderer/r_md3Mesh.c
    ===================================================================
    --- renderer/r_md3Mesh.c        (revision 1518)
    +++ renderer/r_md3Mesh.c        (working copy)
    @@ -231,7 +231,7 @@
                    if (strncmp((const char *)inMesh->id, "IDP3", 4))
                    {
                            VID_Error(ERR_DROP, "mesh %s in model %s has wrong id (%i should be %i)",
    -                               outMesh->name, mod->name, LittleLong((int)inMesh->id), IDMD3HEADER);
    +                               outMesh->name, mod->name, LittleLong((long)inMesh->id), IDMD3HEADER);
                    }
    
                    outMesh->num_tris = LittleLong(inMesh->num_tris);
    Index: renderer/r_model.c
    ===================================================================
    --- renderer/r_model.c  (revision 1518)
    +++ renderer/r_model.c  (working copy)
    @@ -1093,7 +1093,7 @@
    
            // reserve space for neighbour pointers
            // FIXME: pointers don't need to be 4 bytes
    -       poly->neighbours = (glpoly_t **)Mod_Hunk_Alloc(numVerts * 4);
    +       poly->neighbours = (glpoly_t **)Mod_Hunk_Alloc(numVerts * sizeof(void *));
    
            for (i = 0; i < numVerts; i++) {
                    index = currentmodel->surfEdges[fa->firstedge + i];
    @@ -3061,4 +3061,4 @@
    
            return false;
     }
    -#endif
    \ No newline at end of file
    +#endif
    Index: renderer/r_program.c
    ===================================================================
    --- renderer/r_program.c        (revision 1518)
    +++ renderer/r_program.c        (working copy)
    @@ -10,6 +10,7 @@
     ==============================
     */
     #include "r_local.h"
    +#include <ctype.h>
    
     #define MAX_INFO_LOG           4096
    
    Index: server/sv_world.c
    ===================================================================
    --- server/sv_world.c   (revision 1518)
    +++ server/sv_world.c   (working copy)
    @@ -37,7 +37,7 @@
     // (type *)STRUCT_FROM_LINK(link_t *link, type, member)
     // ent = STRUCT_FROM_LINK(link,entity_t,order)
     // FIXME: remove this mess!
    -#define        STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (int)&(((t *)0)->m)))
    +#define        STRUCT_FROM_LINK(l,t,m) ((t *)((byte *)l - (long)&(((t *)0)->m)))
    
     #define        EDICT_FROM_AREA(l) STRUCT_FROM_LINK(l,edict_t,area)
    
    Index: wscript
    ===================================================================
    --- wscript     (revision 1518)
    +++ wscript     (working copy)
    @@ -54,7 +54,7 @@
         #src_dir = bld.path.find_dir('src')
    
         bld.env.append_value('CFLAGS', ['-Wno-unused-result'])
    -    bld.env.append_value('CFLAGS', ['-O3', '-march=native'])
    +    bld.env.append_value('CFLAGS', ['-O0', '-march=native'])
         bld.env.append_value('CFLAGS', ['-fcommon']) 
         bld.env.append_value('CFLAGS', ['-mcmodel=medium'])
    

    With this patch game run without crache.
    But change optimiszation to -O1 cause chrache again

     
  • Kirk Barnes

    Kirk Barnes - 2024-08-24

    таакккк очень интересно.....

     
  • Anonymous

    Anonymous - 2024-08-24

    инлайны убрал, только чтоб с -O0 собралось
    падение в том месте, что в стартовом посте указано лечится вот этой строкой
    poly->neighbours = (glpoly_t *)Mod_Hunk_Alloc(numVerts * sizeof(void ));

    видимо, в коде много мест, где 32-х битные указатели на 64 нужно менять

     
  • Kirk Barnes

    Kirk Barnes - 2024-08-24

    Я понял. А с указателями да, пока что беда + я переносил код на гцц14 и переделал выделение памяти с ориентировкой на х64. На венде то все окей работает...

     
  • Egor

    Egor - 2024-08-25

    плюс еще вот с этим игра уже запускается, будучи собранной с -O2 (да и с -O3)

    $ svn diff -- trunk/renderer/r_vertexObjects.c 
    Index: trunk/renderer/r_vertexObjects.c
    ===================================================================
    --- trunk/renderer/r_vertexObjects.c    (revision 1518)
    +++ trunk/renderer/r_vertexObjects.c    (working copy)
    @@ -184,8 +184,8 @@
    
            float   oneKb = 1024.0f;
            float   oneMb = oneKb * oneKb;
    -       static  int  current;
    -       static  char  output[6][13];
    +       static  int  current = 0;
    +       static  char  output[8][13];
            char    *out = output[current];
    
            current = (current + 1) & (8 - 1);
    @@ -244,4 +244,4 @@
                    qglDeleteBuffers(1, &vb->id);
                    memset(vb, 0, sizeof(*vb));
            }
    -}
    \ No newline at end of file
    +}
    

    Пару уровней прошел - без вылетов пока

     

    Last edit: Egor 2024-08-26
  • Egor

    Egor - 2024-09-22

    еще один фикс. Без него периодически падало, когда стреляешь во врага

    --- game/g_modeltrace.c (revision 1522)
    +++ game/g_modeltrace.c (working copy)
    @@ -142,6 +142,8 @@
            }
     }
    
    +static int model_index_max = sizeof(models) / sizeof(model_to_TRmesh_t);
    +
     modelTR_t* TR_Model_Get(const char* name, int *index){
    
            for (int i = 0; i < sizeof(models) / sizeof(model_to_TRmesh_t); ++i)
    @@ -159,7 +161,7 @@
    
     modelTR_t *TR_Model_Get_by_Index(int index)
     {
    -       if (!index)
    +       if (!index || index > model_index_max)
                    return NULL;
            return models[index - 1].model;
     }
    
    • иногда в TR_Model_Get() индекс передавался мусорный. Откуда - не разбирался. Но и с заглушкой нормально стало работать. Хотя, если мусорный индекс попадет в диапазон 0-25 - возможны баги
     

    Last edit: Egor 2024-09-22
  • Kirk Barnes

    Kirk Barnes - 2024-09-23

    О как! Окей....

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.