summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile14
-rw-r--r--upb/pb/compile_decoder.c4
-rw-r--r--upb/pb/compile_decoder_x64.c2
-rw-r--r--upb/pb/decoder.c4
4 files changed, 17 insertions, 7 deletions
diff --git a/Makefile b/Makefile
index e8f8422..f8af8e2 100644
--- a/Makefile
+++ b/Makefile
@@ -101,6 +101,7 @@ CORE= \
# Library for the protocol buffer format (both text and binary).
PB= \
upb/pb/decoder.c \
+ upb/pb/compile_decoder.c \
upb/pb/glue.c \
upb/pb/varint.c \
@@ -137,7 +138,8 @@ PICOBJ=$(patsubst %.c,%.lo,$(SRC)) $(patsubst %.cc,%.lo,$(SRC))
ifdef USE_JIT
-upb/pb/decoder.o upb/pb/decoder.lo: upb/pb/decoder_x64.h
+PB += upb/pb/compile_decoder_x64.c
+upb/pb/compile_decoder_x64.o upb/pb/comiple_decoder_x64.lo: upb/pb/compile_decoder_x64.h
endif
$(LIBUPB): $(OBJ)
$(E) AR $(LIBUPB)
@@ -172,9 +174,9 @@ upb/def.lo: upb/def.c
$(E) 'CC -fPIC' $<
$(Q) $(CC) $(CFLAGS) $(CPPFLAGS) $(DEF_OPT) -c -o $@ $< -fPIC
-upb/pb/decoder_x64.h: upb/pb/decoder_x64.dasc
+upb/pb/compile_decoder_x64.h: upb/pb/compile_decoder_x64.dasc
$(E) DYNASM $<
- $(Q) $(LUA) dynasm/dynasm.lua upb/pb/decoder_x64.dasc > upb/pb/decoder_x64.h || (rm upb/pb/decoder_x64.h ; false)
+ $(Q) $(LUA) dynasm/dynasm.lua upb/pb/compile_decoder_x64.dasc > upb/pb/compile_decoder_x64.h || (rm upb/pb/compile_decoder_x64.h ; false)
ifneq ($(shell uname), Darwin)
upb/pb/jit_debug_elf_file.o: upb/pb/jit_debug_elf_file.s
@@ -184,7 +186,7 @@ upb/pb/jit_debug_elf_file.o: upb/pb/jit_debug_elf_file.s
upb/pb/jit_debug_elf_file.h: upb/pb/jit_debug_elf_file.o
$(E) XXD $<
$(Q) xxd -i < upb/pb/jit_debug_elf_file.o > upb/pb/jit_debug_elf_file.h
-upb/pb/decoder_x64.h: upb/pb/jit_debug_elf_file.h
+upb/pb/compile_decoder_x64.h: upb/pb/jit_debug_elf_file.h
endif
# Function to expand a wildcard pattern recursively.
@@ -251,8 +253,8 @@ $(SIMPLE_CXX_TESTS): % : %.cc
$(E) CXX $<
$(Q) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ tests/testmain.o $< $(LIBUPB)
-#VALGRIND=valgrind --leak-check=full --error-exitcode=1 --track-origins=yes
-VALGRIND=
+VALGRIND=valgrind --leak-check=full --error-exitcode=1 --track-origins=yes
+#VALGRIND=
test: tests
@set -e # Abort on error.
@for test in $(SIMPLE_TESTS) $(SIMPLE_CXX_TESTS); do \
diff --git a/upb/pb/compile_decoder.c b/upb/pb/compile_decoder.c
index c86a171..200eef5 100644
--- a/upb/pb/compile_decoder.c
+++ b/upb/pb/compile_decoder.c
@@ -623,7 +623,7 @@ static void compile_method(compiler *c, upb_pbdecodermethod *method) {
break;
default: {
opcode parse_type = (opcode)type;
- assert(parse_type >= 0 && parse_type <= OP_MAX);
+ assert((int)parse_type >= 0 && parse_type <= OP_MAX);
upb_selector_t sel = getsel(f, upb_handlers_getprimitivehandlertype(f));
int wire_type = native_wire_types[upb_fielddef_descriptortype(f)];
if (upb_fielddef_isseq(f)) {
@@ -762,6 +762,7 @@ static void sethandlers(upb_pbdecoderplan *p, upb_handlers *h, bool allowjit) {
static bool bind_dynamic(bool allowjit) {
// Bytecode handlers never bind statically.
+ UPB_UNUSED(allowjit);
return true;
}
@@ -797,6 +798,7 @@ upb_string_handler *upb_pbdecoderplan_jitcode(const upb_pbdecoderplan *p) {
#ifdef UPB_USE_JIT_X64
return p->jit_code;
#else
+ UPB_UNUSED(p);
assert(false);
return NULL;
#endif
diff --git a/upb/pb/compile_decoder_x64.c b/upb/pb/compile_decoder_x64.c
index 214ab35..4659716 100644
--- a/upb/pb/compile_decoder_x64.c
+++ b/upb/pb/compile_decoder_x64.c
@@ -280,7 +280,9 @@ void upb_pbdecoder_jit(upb_pbdecoderplan *plan) {
void upb_pbdecoder_freejit(upb_pbdecoderplan *plan) {
if (!plan->jit_code) return;
if (plan->dl) {
+#ifdef UPB_JIT_LOAD_SO
dlclose(plan->dl);
+#endif
} else {
munmap(plan->jit_code, plan->jit_size);
}
diff --git a/upb/pb/decoder.c b/upb/pb/decoder.c
index 0cfb12e..70862d5 100644
--- a/upb/pb/decoder.c
+++ b/upb/pb/decoder.c
@@ -333,6 +333,10 @@ FORCEINLINE int32_t decode_v32(upb_pbdecoder *d, uint32_t *u32) {
if (ret >= 0) return ret;
if (u64 > UINT32_MAX) {
seterr(d, "Unterminated 32-bit varint");
+ // TODO(haberman) guarantee that this function return is >= 0 somehow,
+ // so we know this path will always be treated as error by our caller.
+ // Right now the size_t -> int32_t can overflow and produce negative values.
+ *u32 = 0;
return upb_pbdecoder_suspend(d);
}
*u32 = u64;
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback