23 December 2014

今天在FreeBSD下编译Postgres-XC代码,在运行时总是会core掉,gdb跟踪后发现heap_form_tuple返回的指针到caller总是一部分。开始一位是哪里的bug导致stack内存被踩了,定位了半天没发现线索。后来看到这个 类似的问题,看了一下clang的编译日志,发现下面这个,才恍然大悟:

1082 cc -DPGXC -g3 -gdwarf-2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-stateme nt -Wendif-labels -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv -g -c -o pgxc_class.o pgxc_class.c
1083 pgxc_class.c:81:9: warning: implicit declaration of function ‘heap_form_tuple’ is invalid in C9 9 [-Wimplicit-function-declaration]
1084 htup = heap_form_tuple(pgxcclassrel->rd_att, values, nulls);
1085
1086 pgxc_class.c:81:7: warning: incompatible integer to pointer conversion assigning to ‘HeapTuple’ (aka ‘struct HeapTupleData *’) from ‘int’ [-Wint-conversion]
1087 htup = heap_form_tuple(pgxcclassrel->rd_att, values, nulls);
1088 ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

做多了了c++,java,shell,搞C开发,坑和细枝末节太多了,要时刻小心。