[colm] colm-0.13.0.5 fails to build on IA32

Jan Engelhardt jengelh at inai.de
Tue Jun 13 08:59:11 UTC 2017


On Tuesday 2017-06-13 00:58, Adrian Thurston wrote:

>Hmm I tried to reproduce this the other day on a fresh Ubuntu VM but
>couldn't.  Can you give more platform information?

It would appear that this only triggers when built on the workers of
build.opensuse.org, and not even on a local same-setup chroot. So
that's for me to investigate then.

Meanwhile, I tried poking blindly at the compiler warnings - which
should always appear with gcc7, independent of hardware instance -
instead to see if they would lead up to this. There are some:

1. 

[   96s] bytecode.c: In function 'colm_rcode_downref_all':
[   96s] bytecode.c:4549:4: warning: 'w' may be used uninitialized in this function [-Wmaybe-uninitialized]
[   96s]     colm_tree_downref( prg, sp, w );
[   96s]     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[   96s] bytecode.c:4546:12: note: 'w' was declared here
[   96s]     tree_t *w;
[   96s]             ^
[   97s] In file included from bytecode.c:23:0:
[   97s] bytecode.c: In function 'colm_execute_code':
[   97s] include/colm/bytecode.h:522:80: warning: 'w' may be used uninitialized in this function [-Wmaybe-uninitialized]
[   97s]   ( ( sp == prg->sb_beg ? (sp = vm_bs_add(prg, sp, 1)) : 0 ), (*((type*)(--sp)) = (i)) )
[   97s]                                                                                 ^
[   97s] bytecode.c:626:11: note: 'w' was declared here
[   97s]     word_t w;
[   97s]            ^


src/bytecode.c: There is some shadowing going on. Because the "i"
parameter expands to "w" in at least one case, it will
execute  w = (type) w, which is silly. The fix:

@@ -54,12 +55,12 @@
 #if SIZEOF_LONG == 4
 
        #define read_type( type, i ) do { \
-               word_t w; \
-               w = ((word_t) *instr++); \
-               w |= ((word_t) *instr++) << 8; \
-               w |= ((word_t) *instr++) << 16; \
-               w |= ((word_t) *instr++) << 24; \
-               i = (type) w; \
+               word_t _w; \

You also need i = (type)(uintptr_t)w.



2. Built with -fsanitize=undefined, and a place in parsetree.h gets
flagged for passing nullptr to memcpy. Added this throw to check,
and indeed...


        ObjectMethod( UniqueType *returnUT, String name, 
                        int opcodeWV, int opcodeWC, int numParams, 
                        UniqueType **types, ParameterList *paramList,
                        bool isConst )
...
	{
                 this->paramUTs = new UniqueType*[numParams];                                                            
+                if (types == nullptr && numParams == 0) {                                                               
+                       /* well alright */                                                                              
+                } else {                                                                                                
+                        throw int(42);                                                                                  
+                }                                                                                                       
!                memcpy( this->paramUTs, types, sizeof(UniqueType*)*numParams );                                         



3. loadcolm.cc: In member function ‘void LoadColm::walkInHostDef(in_host_def)’:
loadcolm.cc:2224:62: warning: ‘type’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   return addParam( paramVarDef.id().loc(), type, typeRef, id );
                                                              ^
loadcolm.cc:2211:21: note: ‘type’ was declared here
   ObjectField::Type type;





More information about the colm-users mailing list