Bug ID 1042012
Summary Latest gcc 7-1.2 cause crash
Classification openSUSE
Product openSUSE Tumbleweed
Version Current
Hardware x86
OS openSUSE 42.2
Status NEW
Severity Normal
Priority P5 - None
Component Development
Assignee bnc-team-screening@forge.provo.novell.com
Reporter werner@suse.com
QA Contact qa-bugs@suse.de
Found By ---
Blocker ---

Latest gcc in openSUSE Factory cause a segmentation fault with the following
code (see function below) 


 void* to_cdata(lua_State* L, int idx, struct ctype* ct)
 {
     struct cdata* cd;

     memset(ct, 0, sizeof(struct ctype));
     if (!lua_isuserdata(L, idx) || !lua_getmetatable(L, idx)) {
         lua_pushnil(L);
         return NULL;
     }

     if (!equals_upval(L, -1, &cdata_mt_key)) {
         lua_pop(L, 1); /* mt */
         lua_pushnil(L);
         return NULL;
     }

     lua_pop(L, 1); /* mt */
     cd = (struct cdata*) lua_touserdata(L, idx);
     if (!cd) {
         lua_pushnil(L);
         return NULL;
     }
     *ct = cd->type;
^^^^^^^^^^^^^^^^^^^
     lua_getuservalue(L, idx);

     if (ct->is_reference) {
         return *(void**) (cd+1);

     } else if (ct->pointers && !ct->is_array) {
         return *(void**) (cd+1);

     } else {
         return cd + 1;
     }
 }

the assignment does work with gcc-6 flawless.  I've also checked the code in
the debugger and found that cd->type as well as ct are valid.  Don't know if
gcc-7 has a flags to allow that pointers in the arguments of a function can be
changed within the functions.


You are receiving this mail because: