Closed thedrow closed 10 years ago
which test case?
Yeah, two test cases are failed:
check_tree.c:274:F:testcase:test_pcre_pattern_simple:0: Assertion 'matched' failed check_tree.c:307:F:testcase:test_pcre_pattern_more:0: Assertion 'matched' failed
can you take a look?
also please merge our master HEAD. thanks :)
You can fetch the branch thedrow-topic/zmalloc
, in which I have merged your changes with the master HEAD.
I just rebased.
I'll take yours then. Why is it failing? I have no idea.
build result: https://travis-ci.org/c9s/r3/jobs/25624754
you need to update configure.ac 0211a7f and check flags used in src/Makefile.am , tests/Makefile.am
after you updated the configure.ac and Makefile.am, you should run autoconf
, automake
Wait, the whole point of zmalloc is to make jemalloc/tcmalloc optional. We need to detect if any of them are installed already and configure the config.h accordingly.
I really don't understand the testrunner output. I'm used to python where I get the line the error occurred. Can you point me to the right direction?
You can run tests/check_tree separately, or use gdb to debug it, the binary should be in tests/.libs or something.
If its a segfault, gdb 'bt' backtrace shall help u find the correct entry point
Please assume I don't know anything and explain in details because I've never once debugged through a command line in my life :P
Hmm ubuntu doesn't install the pc (used by pkg-config) file for jemalloc. Is there a way to fix it?
Ok, so the build process should generate a pc file much like https://github.com/openwebos/jemalloc/blob/master/files/pkgconfig/jemalloc.pc.in. i just made up something that works.
I run the program using gdb and bt says no stack afterwards.
So it's not a segfault and valgrind says no leak is found. What else?
Here is the valgrind log: https://gist.github.com/thedrow/3706961dbe5e516832ff
It seems only pcre related tests failed?
And edge.c does not know zmalloc function (see the gcc warnings)
Could it be because it uses another malloc and not jemalloc?
And I don't get any warning about edge.c.
Hi! I am back, try running ./configure with --enable-debug
which adds the -ggdb
flags to the build process.
and you need to make sure any source file calling z* functions should include the "zmalloc.h"
And you're calling zcalloc
without element size * element numbers, I saw there is only element numbers.
You need to call zcalloc
just like this:
zcalloc(sizeof(int) * 10)
not just zcalloc(10)
https://github.com/thedrow/r3/blob/topic/zmalloc/src/node.c#L161
But that one is a char no?
I just did the changes locally and it has no effect.
Yes, it's char.
Well, I think you need to correct the allocation calls and commit them. and see what else we can do.
There are two calls actually:
src/node.c:160: cpat = zcalloc(128);
src/node.c:192: n->ov = (int*) zcalloc(n->ov_cnt);
I saw those. I get the same errors. I'll commit in an hour.
Btw, is there a reason why cpat is not freed at the end of the method?
the cpat means combined_pattern
which is used for pcre and tree dumping & debugging (we can see the compiled regexp)
https://gist.github.com/c9s/e0ef1f0a1f78e6adedb2 I saw a lot of compiler warnings, which might cause the matching fails. you might need to fix them all
You may fetch my commit de5a308 on the thedrow-topic/zmalloc
branch which fixes most warnings.
Fetched and done.
OK, I've checked the last build failing message: https://travis-ci.org/c9s/r3/jobs/25671096
seems like it calls zfree at wrong pointer:
/lib/x86_64-linux-gnu/libc.so.6(+0x7e626)[0x2ae981b4e626]
/home/travis/build/c9s/r3/src/.libs/libr3.so.0(zfree+0x52)[0x2ae9818b4aa2]
/home/travis/build/c9s/r3/src/.libs/libr3.so.0(r3_edge_branch+0x129)[0x2ae9818b3d29]
/home/travis/build/c9s/r3/src/.libs/libr3.so.0(r3_tree_insert_pathl_+0x18e)[0x2ae9818b38ee]
/home/travis/build/c9s/r3/tests/.libs/lt-check_tree[0x403f20]
And here are the failing test cases (segment faults)
check_tree.c:185:E:testcase:testr3_tree_insert_pathl:0: (after this point) Received signal 6 (Aborted)
check_tree.c:45:E:testcase:test_compile:0: (after this point) Received signal 6 (Aborted)
check_tree.c:265:E:testcase:test_pcre_pattern_simple:0: (after this point) Received signal 6 (Aborted)
check_tree.c:284:E:testcase:test_pcre_pattern_more:0: (after this point) Received signal 11 (Segmentation fault)
check_tree.c:115:E:testcase:test_pcre_patterns_insert:0: (after this point) Received signal 6 (Aborted)
check_tree.c:125:E:testcase:test_pcre_patterns_insert_2:0: (after this point) Received signal 6 (Aborted)
check_tree.c:144:E:testcase:test_pcre_patterns_insert_3:0: (after this point) Received signal 6 (Aborted)
check_tree.c:363:E:testcase:benchmark_str:0: (after this point) Received signal 6 (Aborted)
You may comment all but keep one test case to narrow down the problem.
I guess the key is inside the edge_branch function.
Oh crap. This is from the workplace's user... wait.
Well for some reason I can't replace it. Nevermind...
it's OK :)
seems like we have other places using strndup
instead of zstrndup
?
src/edge.c:58: e1 = r3_edge_create(strndup(s1, s1_len), s1_len, new_child);
src/edge.c:75: e->pattern = strndup(e->pattern, dl);
src/node.c:309: str_array_append(entry->vars , strndup(substring_start, substring_length));
src/node.c:462: r3_node_add_child(n, strndup(path, (int)(p - path)), child);
src/node.c:469: r3_node_add_child(n, strndup(path, path_len) , child);
I saw there is a zstrdup
in zmalloc.c
but there is no zstrndup
, we need to implement one.
What's the difference?
@c9s Got it. What's next?
zstrndup is to avoid lenght calculation
So why is this still failing?
You may check the incompatible pointer warnings.
Also there is another segment fault in tree_free function.
Did we set NULL to pcre related variables when creating node or tree?
I have no idea. Can you please try to debug this since I'm a bit lost.
As far as I can see all of them are set to NULL when creating both node and tree.
There's still a failing test that I can't track. Care to help?