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

signal SIGSEGV, Segmentation fault on return #159

Closed
omerbrandis opened this issue Apr 7, 2021 · 3 comments
Closed

signal SIGSEGV, Segmentation fault on return #159

omerbrandis opened this issue Apr 7, 2021 · 3 comments

Comments

@omerbrandis
Copy link

omerbrandis commented Apr 7, 2021

hello ,

I'm getting :
Program terminated with signal SIGSEGV, Segmentation fault.
#0 __GI___libc_free (mem=0x10172d1f1) at malloc.c:2951

this happes on method return statement .
method uses csv parser & decimal_for_cpp , i think its something about their interaction ...

this is the back trace from the generated core file:
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007fc57a18c512 in ?? ()
[Current thread is 1 (LWP 14230)]
(gdb) bt
#0 0x00007fc57a18c512 in ?? ()
#1 0x00007ffe00000000 in ?? ()
#2 0x000000000172d130 in ?? ()
#3 0x000000000172d120 in ?? ()
#4 0x00007ffea71201f8 in ?? ()
#5 0x0000000000000042 in ?? ()
#6 0x0000000000000042 in ?? ()
#7 0x00007ffea711ff80 in ?? ()
#8 0x000000010172d1f1 in ?? ()
#9 0x00007ffea7120750 in ?? ()
#10 0x00000000004211e8 in std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<unsigned long, false> > >::_M_deallocate_buckets (this=0x10172d1f1, __bkts=0x7ffea711ff80, __n=66)
at /usr/include/c++/7/bits/hashtable_policy.h:2119
#11 0x000000000041c171 in std::_Vector_base<csv::internals::RawCSVField*, std::allocatorcsv::internals::RawCSVField* >::_Vector_impl::_Vector_impl (this=0x7ffea7120410)
at /usr/include/c++/7/bits/stl_vector.h:88
#12 0x000000000041797a in std::_Hashtable<std::__cxx11::basic_string<char, std::char_traits, std::allocator >, std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator > const, unsigned long>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits, std::allocator > const, unsigned long> >, std::__detail::_Select1st, std::equal_to<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::hash<std::__cxx11::basic_string<char, std::char_traits, std::allocator > >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<true, false, true> >::_M_deallocate_buckets (this=0x7ffea7120030)
at /usr/include/c++/7/bits/hashtable.h:368
#13 0x000000000041765e in std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_set_length (
this=0x41765e <std::__cxx11::basic_string<char, std::char_traits, std::allocator >::_M_set_length(unsigned long)+90>, __n=140731701395456) at /usr/include/c++/7/bits/basic_string.h:206
#14 0x0000000000412572 in std::__cxx11::basic_string<char, std::char_traits, std::allocator >::~basic_string (this=0x7ffea7120410, __in_chrg=)
at /usr/include/c++/7/bits/basic_string.h:647
#15 0x0000000000409fee in MainWindow::MainWindow (this=0x7ffea7120610, parent=0x0) at ../mainwindow.cpp:74
#16 0x00000000004092cf in main (argc=1, argv=0x7ffea7120758) at ../main.cpp:7

i've tried to debug it a little.
creating the csv::CSVReader object is not the cause.
reading the data is not the problem. (for (auto& row: MyCsvReader))

using strings is somehow causing the problem.
but have not yet found the logic to it :

code :
for (auto& row: MyCsvReader)
{
LongitudeAsString = row["Longitude"].getstd::string();
LatitudeString = row["Latitude"].getstd::string();
}

as is, works without the segfaut.

adding
Dec8Longitude = DEC_NAMESPACE::fromString<DEC_NAMESPACE::decimal<8>>(LongitudeAsString);

still works.

adding Dec8Latitude = DEC_NAMESPACE::fromString<DEC_NAMESPACE::decimal<8>>(LatitudeString);
leads to the crash.

tried
Dec8Latitude = DEC_NAMESPACE::fromString<DEC_NAMESPACE::decimal<8>>("2"); -> no crash.

tried
reusing same std::string twice
Dec8Longitude = DEC_NAMESPACE::fromString<DEC_NAMESPACE::decimal<8>>(LatitudeString)
Dec8Latitude = DEC_NAMESPACE::fromString<DEC_NAMESPACE::decimal<8>>(LatitudeString);
no crash. ( leads me to think its not the data in the file )

please advise,
Omer.

@omerbrandis
Copy link
Author

( i've also opened an issue at dec for cpp ...vpiotr/decimal_for_cpp#49 )

@omerbrandis
Copy link
Author

may have tracked it to something else ( in my code ) , but not closing this issue yet.

@omerbrandis
Copy link
Author

my bad, corrupted the stack later in the code with the actual value...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant