Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<ab.json jtc -w'<address>l[:]<Lbl>k<>k' -u"$map" -u'>Lbl<t' / -w'<address>l' fails with SEGV #27

Closed
D4N opened this issue Jun 9, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@D4N
Copy link
Contributor

D4N commented Jun 9, 2020

The following example from User Guide.md:

bash $ map='{"postal code":"zip","street address":"street"}'
bash $ <ab.json jtc -w'<address>l[:]<Lbl>k<>k' -u"$map" -u'>Lbl<t' / -w'<address>l'

results in a crash:

AddressSanitizer:DEADLYSIGNAL
=================================================================
==240254==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000008 (pc 0x7f2f272dc3ee bp 0x7ffd929298d0 sp 0x7ffd92928e18 T0)
==240254==The signal is caused by a READ memory access.
==240254==Hint: address points to the zero page.
    #0 0x7f2f272dc3ee in std::_Rb_tree_decrement(std::_Rb_tree_node_base*) (/lib64/libstdc++.so.6+0xc33ee)
    #1 0x5d8c65 in std::_Rb_tree_iterator<std::pair<unsigned long const, Json> >::operator--() /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/stl_tree.h:302:12
    #2 0x5d8c65 in std::reverse_iterator<std::_Rb_tree_iterator<std::pair<unsigned long const, Json> > >::operator->() const /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/stl_iterator.h:228:2
    #3 0x5d8c65 in Jtc::advance_to_next_src(Json::iterator&, long) /home/dan/projects/github.com/ldn-softdev/jtc/jtc.cpp:1761:41
    #4 0x5d9f14 in Jtc::advance_to_next_src(Json::iterator&, long) /home/dan/projects/github.com/ldn-softdev/jtc/jtc.cpp
    #5 0x5cc962 in Jtc::collect_itr_bindings(Json::iterator&, Jtc::Grouping) /home/dan/projects/github.com/ldn-softdev/jtc/jtc.cpp:1704:8
    #6 0x5ee68b in Jtc::process_offsets_(std::deque<std::deque<Json::iterator, std::allocator<Json::iterator> >, std::allocator<std::deque<Json::iterator, std::allocator<Json::iterator> > > >&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, unsigned long, std::vector<unsigned long, std::allocator<unsigned long> >&) /home/dan/projects/github.com/ldn-softdev/jtc/jtc.cpp:2770:2
    #7 0x5ec516 in Jtc::process_walk_iterators_(std::deque<std::deque<Json::iterator, std::allocator<Json::iterator> >, std::allocator<std::deque<Json::iterator, std::allocator<Json::iterator> > > >&) /home/dan/projects/github.com/ldn-softdev/jtc/jtc.cpp:2694:2
    #8 0x5cb111 in Jtc::walk_interleaved_(void (Jtc::*)(Json::iterator&, Jtc::Grouping)) /home/dan/projects/github.com/ldn-softdev/jtc/jtc.cpp:2678:3
    #9 0x5c5c86 in Jtc::upsert_json(char) /home/dan/projects/github.com/ldn-softdev/jtc/jtc.cpp:1666:2
    #10 0x5bc2e6 in Jtc::demux_opt() /home/dan/projects/github.com/ldn-softdev/jtc/jtc.cpp:1530:37
    #11 0x5b9cfb in run_single_optset(CommonResource&, Streamstr::const_iterator&, Json&, Json&) /home/dan/projects/github.com/ldn-softdev/jtc/jtc.cpp:914:29
    #12 0x5b6c47 in run_decomposed_optsets(CommonResource&, Streamstr::const_iterator&) /home/dan/projects/github.com/ldn-softdev/jtc/jtc.cpp:888:3
    #13 0x5b00cb in main /home/dan/projects/github.com/ldn-softdev/jtc/jtc.cpp:814:6
    #14 0x7f2f26f01041 in __libc_start_main (/lib64/libc.so.6+0x27041)
    #15 0x47850d in _start (/home/dan/projects/github.com/ldn-softdev/jtc/jtc+0x47850d)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV (/lib64/libstdc++.so.6+0xc33ee) in std::_Rb_tree_decrement(std::_Rb_tree_node_base*)
==240254==ABORTING
@ldn-softdev
Copy link
Owner

I'll take a look. It seems another Linux-specific failure (under MacOS the sanitizer does not catch this, nor jtc crashes). Thanks for catching.

@ldn-softdev ldn-softdev added the bug Something isn't working label Jun 10, 2020
@ldn-softdev
Copy link
Owner

ldn-softdev commented Jun 10, 2020

This one is indeed a bug, which should even occur on the MacOS, but for some reasons the MacOS is tolerant to this issue (hence it sneaks past the unit test):

when resolving a value via the reverse iterator, an empty std::map (in this case jtmp_.rbegin()->VALUE) it should produce a seg fault (which is observed on LInux, but it's not observed on the MacOS).

the fix will be pushed soon together with the other reported issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants