Skip to content

Sometimes segmentation fault in rx.cpp #2

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

Closed
dujeonglee opened this issue Apr 24, 2017 · 1 comment
Closed

Sometimes segmentation fault in rx.cpp #2

dujeonglee opened this issue Apr 24, 2017 · 1 comment
Labels

Comments

@dujeonglee
Copy link
Owner

dujeonglee commented Apr 24, 2017

                if((*pp_block)->m_DecodingReady)
                {
                    p_block = (*pp_block);
                    if(p_block->Decoding())
                    {
                        c_Session->m_SequenceNumberForService++;
                    }
                }
                else
                {
                    for(u08 i = 0 ; i < (*pp_block)->m_DecodedPacketBuffer.size() ; i++)
                    {
                        if(i != reinterpret_cast<Header::Data*>((*pp_block)->m_DecodedPacketBuffer[i].get())->m_ExpectedRank-1)
                        {
                            break;
                        }
                        do
                        {
                            u08* pkt;
                            try
                            {
                                TEST_EXCEPTION(std::bad_alloc());
                                pkt = new u08[reinterpret_cast<Header::Data*>((*pp_block)->m_DecodedPacketBuffer[i].get())->m_TotalSize];
                     This Line->memcpy(pkt, (*pp_block)->m_DecodedPacketBuffer[i].get(), reinterpret_cast<Header::Data*>((*pp_block)->m_DecodedPacketBuffer[i].get())->m_TotalSize); <- This line.
                                while(c_Session->m_RxTaskQueue.Enqueue([this, pkt](){
                                    c_Reception->m_RxCallback(pkt+sizeof(Header::Data)+reinterpret_cast<Header::Data*>(pkt)->m_MaximumRank-1, ntohs(reinterpret_cast<Header::Data*>(pkt)->m_PayloadSize), &c_Session->m_SenderAddress, sizeof(c_Session->m_SenderAddress));
                                    delete [] pkt;
                                })==false);
                                reinterpret_cast<Header::Data*>((*pp_block)->m_DecodedPacketBuffer[i].get())->m_Flags |= Header::Data::DataHeaderFlag::FLAGS_CONSUMED;
                                break;
                            }
                            catch (const std::bad_alloc& ex)
                            {
                                EXCEPTION_PRINT;
                            }
                        }
                        while(1);
                    }
                    break;
                }

Stack Trace
__memcpy_avx_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S:238
238 ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S: No such file or directory.
(gdb) bt
#0 __memcpy_avx_unaligned () at ../sysdeps/x86_64/multiarch/memcpy-avx-unaligned.S:238
#1 0x000000000041f490 in NetworkCoding::ReceptionBlock::Receive (this=0x7fffe0089ea0,
buffer=0x7ffff6f4e880 "\001\004\024\t%\t(\t5\004\004\002", <incomplete sequence \302>, length=1044, sender_addr=0x7ffff6f4e7f0,
sender_addr_len=16) at rx.cpp:492
#2 0x0000000000420101 in NetworkCoding::ReceptionSession::Receive (this=0x7fffe00008c0,
buffer=0x7ffff6f4e880 "\001\004\024\t%\t(\t5\004\004\002", <incomplete sequence \302>, length=1044, sender_addr=0x7ffff6f4e7f0,
sender_addr_len=16) at rx.cpp:615
#3 0x000000000042042b in NetworkCoding::Reception::RxHandler (this=0x65a5e0,
buffer=0x7ffff6f4e880 "\001\004\024\t%\t(\t5\004\004\002", <incomplete sequence \302>, size=1044, sender_addr=0x7ffff6f4e7f0,
sender_addr_len=16) at rx.cpp:640
#4 0x000000000042668e in NetworkCoding::NCSocket::NCSocket(unsigned short, long, long, std::function<void (unsigned char*, unsigned short, sockaddr_in const*, unsigned int)>)::{lambda()#1}::operator()() const () at ncsocket.h:124
#5 0x00000000004283be in std::_Bind_simple<NetworkCoding::NCSocket::NCSocket(unsigned short, long, long, std::function<void (unsigned char*, unsigned short, sockaddr_in const*, unsigned int)>)::{lambda()#1} ()>::_M_invoke<>(std::_Index_tuple<>) (this=0x65a6b8)
at /usr/include/c++/5/functional:1531
#6 0x0000000000428314 in std::_Bind_simple<NetworkCoding::NCSocket::NCSocket(unsigned short, long, long, std::function<void (unsigned char*, unsigned short, sockaddr_in const*, unsigned int)>)::{lambda()#1} ()>::operator()() (this=0x65a6b8) at /usr/include/c++/5/functional:1520
#7 0x00000000004282a4 in std::thread::_Impl<std::_Bind_simple<NetworkCoding::NCSocket::NCSocket(unsigned short, long, long, std::function<void (unsigned char*, unsigned short, sockaddr_in const*, unsigned int)>)::{lambda()#1} ()> >::_M_run() (this=0x65a6a0)
at /usr/include/c++/5/thread:115
#8 0x00007ffff78f0c80 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#9 0x00007ffff7bc16ba in start_thread (arg=0x7ffff6f4f700) at pthread_create.c:333
#10 0x00007ffff735f82d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
(gdb)

@dujeonglee dujeonglee added the bug label Apr 24, 2017
@dujeonglee dujeonglee changed the title Segmentation fault. Sometimes segmentation fault in rx.cpp Apr 24, 2017
@dujeonglee
Copy link
Owner Author

m_TotalSize are 2bytes.
One must access the field using ntohs.

@dujeonglee dujeonglee mentioned this issue Jan 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant