The point of the question
I have a minimal program that segfaults during sycl runtime compilation. For the sake of detail i have precise reproduction details below. However, the point of this question is to understand how to debug this. It took me a long time to make the minimal example. I suspect if i could get the runtimes for dpcpp i could probably have cut this right down. When the runtime compiler fails, it should throw an exception. I want to know what steps i should take to discover why it is instead segfaulting, and if it is a compiler bug or a bug in my code.
Reproduction details below
starting with the code:
#include <CL/sycl/queue.hpp>
#include <CL/sycl/device.hpp>
#include <CL/sycl/context.hpp>
#include <CL/sycl.hpp>
#include <iostream>
namespace
{
auto is_sign_same(sycl::short3 idx1, sycl::short3 idx2)
{
return (idx1 < 0) == (idx2 < 0);
}
} // namespace
int main()
{
sycl::device device = sycl::device{sycl::gpu_selector{}};
std::cout
<< "\n\nRunning occupancy grid profile. The profile will have the following "
"properties:\n\n Device:\t"
<< device.get_info<sycl::info::device::name>() << "\n\n";
sycl::context context{device};
sycl::property_list properties{sycl::property::queue::enable_profiling()};
sycl::queue queue{device, properties};
auto event = queue.submit(
[](sycl::handler& cgh)
{
// 1. This must be captured or it does not crash. If i put this in the
// kernel, then it does not fail.
sycl::id<3> robot_index{0, 0, 0};
sycl::stream out(1024, 256, cgh);
cgh.parallel_for(
sycl::range<3>{4, 4, 4},
[out, robot_index](sycl::id<3> id)
{
sycl::short3 new_signed_idx{short(0)};
// 2. I cannot remove the subtract between the 2 sycl::short3 here.
// It will not fail.
sycl::short3 old_signed_idx =
sycl::short3{
(short)id.get(0), (short)id.get(1), (short)id.get(2)} -
sycl::short3{
(short)robot_index.get(0),
(short)robot_index.get(1),
(short)robot_index.get(2)};
// 3. I cannot replace this function call with the operation that
// the function performs inline here. It does not fail.
auto s_same = is_sign_same(new_signed_idx, old_signed_idx);
out << s_same;
}
);
}
);
return 0;
}
When compiled using:
/opt/intel/oneapi/compiler/2022.1.0/linux/bin/dpcpp -fclang-abi-compat=7 -fsycl --gcc-toolchain=/usr -sycl-std=2020 -fp-model=precise -Wall -Werror -fsycl -O2 -g -DNDEBUG -std=gnu++17 sgfaulting_file.cpp
will fail at runtime. The failure is a segfault. It is caused by something do do with building the kernel. If we run the output in GDB we get the following stack trace when it dies:
(gdb) where
#0 0x00007f49e3683b8c in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#1 0x00007f49e36b440c in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#2 0x00007f49e36b0dda in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#3 0x00007f49e36b430f in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#4 0x00007f49e36bac6a in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#5 0x00007f49e36b0bed in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#6 0x00007f49e36b430f in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#7 0x00007f49e36bac6a in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#8 0x00007f49e36bf027 in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#9 0x00007f49e36bf908 in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#10 0x00007f49e35ab7bc in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#11 0x00007f49e35abfba in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#12 0x00007f49e35ae90d in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#13 0x00007f49e36ec3d4 in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#14 0x00007f49e35b21fb in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#15 0x00007f49e36ced9a in ?? () from /usr/lib/x86_64-linux-gnu/libigc.so.1
#16 0x00007f49f487f1bb in ?? () from /usr/lib/x86_64-linux-gnu/intel-opencl/libigdrcl.so
#17 0x00007f49f43ef178 in ?? () from /usr/lib/x86_64-linux-gnu/intel-opencl/libigdrcl.so
#18 0x00007f49f4397b33 in ?? () from /usr/lib/x86_64-linux-gnu/intel-opencl/libigdrcl.so
#19 0x00007f49f9327aa4 in cl::sycl::detail::ProgramManager::build(std::unique_ptr<_pi_program, _pi_result (*)(_pi_program*)>, std::shared_ptr<cl::sycl::detail::context_impl>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, _pi_device* const&, std::map<std::pair<cl::sycl::detail::DeviceLibExt, _pi_device*>, _pi_program*, std::less<std::pair<cl::sycl::detail::DeviceLibExt, _pi_device*> >, std::allocator<std::pair<std::pair<cl::sycl::detail::DeviceLibExt, _pi_device*> const, _pi_program*> > >&, unsigned int) () from /opt/intel/oneapi/compiler/2022.1.0/linux/lib/libsycl.so.5
#20 0x00007f49f9321336 in cl::sycl::detail::ProgramManager::getBuiltPIProgram(long, std::shared_ptr<cl::sycl::detail::context_impl> const&, std::shared_ptr<cl::sycl::detail::device_impl> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cl::sycl::detail::program_impl const*, bool) () from /opt/intel/oneapi/compiler/2022.1.0/linux/lib/libsycl.so.5
#21 0x00007f49f932243c in cl::sycl::detail::ProgramManager::getOrCreateKernel(long, std::shared_ptr<cl::sycl::detail::context_impl> const&, std::shared_ptr<cl::sycl::detail::device_impl> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cl::sycl::detail::program_impl const*) () from /opt/intel/oneapi/compiler/2022.1.0/linux/lib/libsycl.so.5
#22 0x00007f49f93630f1 in cl::sycl::detail::enqueueImpKernel(std::shared_ptr<cl::sycl::detail::queue_impl> const&, cl::sycl::detail::NDRDescT&, std::vector<cl::sycl::detail::ArgDesc, std::allocator<cl::sycl::detail::ArgDesc> >&, std::shared_ptr<cl::sycl::detail::kernel_bundle_impl> const&, std::shared_ptr<cl::sycl::detail::kernel_impl> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, long const&, std::vector<_pi_event*, std::allocator<_pi_event*> >&, _pi_event**, std::function<void* (cl::sycl::detail::AccessorImplHost*)> const&) ()
from /opt/intel/oneapi/compiler/2022.1.0/linux/lib/libsycl.so.5
#23 0x00007f49f9369f3b in cl::sycl::detail::ExecCGCommand::enqueueImp() ()
from /opt/intel/oneapi/compiler/2022.1.0/linux/lib/libsycl.so.5
#24 0x00007f49f93566c5 in cl::sycl::detail::Command::enqueue(cl::sycl::detail::EnqueueResultT&, cl::sycl::detail::BlockingT, std::vector<cl::sycl::detail::Command*, std::allocator<cl::sycl::detail::Command*> >&) () from /opt/intel/oneapi/compiler/2022.1.0/linux/lib/libsycl.so.5
#25 0x00007f49f9373b7b in cl::sycl::detail::Scheduler::addCG(std::unique_ptr<cl::sycl::detail::CG, std::default_delete<cl::sycl::detail::CG> >, std::shared_ptr<cl::sycl::detail::queue_impl>) ()
from /opt/intel/oneapi/compiler/2022.1.0/linux/lib/libsycl.so.5
#26 0x00007f49f93aef30 in cl::sycl::handler::finalize() ()
from /opt/intel/oneapi/compiler/2022.1.0/linux/lib/libsycl.so.5
#27 0x00007f49f93dc3ea in cl::sycl::detail::queue_impl::finalizeHandler(cl::sycl::handler&, cl::sycl::detail::CG::CGTYPE const&, cl::sycl::event&) ()
from /opt/intel/oneapi/compiler/2022.1.0/linux/lib/libsycl.so.5
#28 0x00007f49f93dc13b in cl::sycl::detail::queue_impl::submit_impl(std::function<void (cl::sycl::handler&)> const&, std::shared_ptr<cl::sycl::detail::queue_impl> const&, std::shared_ptr<cl::sycl::detail::queue_impl> const&, std::shared_ptr<cl::sycl::detail::queue_impl> const&, cl::sycl::detail::code_location const&, std::function<void (bool, bool, cl::sycl::event&)> const*) ()
from /opt/intel/oneapi/compiler/2022.1.0/linux/lib/libsycl.so.5
#29 0x00007f49f93db744 in cl::sycl::detail::queue_impl::submit(std::function<void (cl::sycl::handler&)> const&, std::shared_ptr<cl::sycl::detail::queue_impl> const&, cl::sycl::detail::code_location const&, std:--Type <RET> for more, q to quit, c to continue without paging--
:function<void (bool, bool, cl::sycl::event&)> const*) ()
from /opt/intel/oneapi/compiler/2022.1.0/linux/lib/libsycl.so.5
#30 0x00007f49f93db715 in cl::sycl::queue::submit_impl(std::function<void (cl::sycl::handler&)>, cl::sycl::detail::code_location const&) () from /opt/intel/oneapi/compiler/2022.1.0/linux/lib/libsycl.so.5
#31 0x00000000004026d8 in cl::sycl::queue::submit<main::{lambda(cl::sycl::handler&)#1}>(main::{lambda(cl::sycl::handler&)#1}, cl::sycl::detail::code_location const&) (this=0x7ffc5da1b200, CodeLoc=..., CGF=...)
at /opt/intel/oneapi/compiler/2022.1.0/linux/bin-llvm/../include/sycl/CL/sycl/queue.hpp:275
#32 main () at occupancy_grid_point_cloud_creation.cpp:31
The important part being stack position #19:
cl::sycl::detail::ProgramManager::build
The runtime compilation is occurring on the device (from sycl-ls):
[opencl:gpu:2] Intel(R) OpenCL HD Graphics, Intel(R) UHD Graphics [0x9bc4] 3.0 [22.28.23726.1]
if we run the same program but use a host or cpu selector, we do not fail to build and can run successfully. It also seems that if we change minimal details about the program, it also no longer segfaults. These small changes are detailed in the comments in the program.
Related
I'm trying to get the fps from multiple cameras. This is the main:
int main(int argc, char* argv[])
{
//Load all cameras IP
map<string, string> camerasIp; //camera ID and Streaming URL
LoadConfig(&camerasIp);
//Get FPS of all cameras
map<string,string>::iterator it_cam;
while(true)
{
for(it_cam = camerasIp.begin(); it_cam != camerasIp.end(); ++it_cam)
{
GetCamFps(it_cam->second);
}
cout << "" << endl;
}
//Send FPS to server
...
return 0;
}
This is the GetCamFps method:
void GetCamFps(string url)
{
cout << "VideoCapture" << endl;
VideoCapture video(url);
cout << "Get frames" << endl;
double fps = video.get(CAP_PROP_FPS);
cout <<"Frames: " << fps << endl;
video.release();
}
And this is the exit:
VideoCapture
Get frames
Frames: 30
VideoCapture
corrupted double-linked list
Aborted (core dumped)
I tried adding a sleep to let some time between opening one url and another but didn't works. I checked the map and it's correct.
When I comment the two firsts cout in the method it works but after a while it fail again.
Output of gdb with backtrace:
Thread 1 "Fps_Monitoring" received signal SIGABRT, Aborted.
__GI_raise (sig=sig#entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) backtrace
#0 __GI_raise (sig=sig#entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x00007ffff51cc801 in __GI_abort () at abort.c:79
#2 0x00007ffff5215897 in __libc_message (action=action#entry=do_abort, fmt=fmt#entry=0x7ffff5342b9a "%s\n") at ../sysdeps/posix/libc_fatal.c:181
#3 0x00007ffff521c90a in malloc_printerr (str=str#entry=0x7ffff5340cba "corrupted double-linked list") at malloc.c:5350
#4 0x00007ffff521cac4 in malloc_consolidate (av=av#entry=0x7ffff5577c40 <main_arena>) at malloc.c:4456
#5 0x00007ffff52207d8 in _int_malloc (av=av#entry=0x7ffff5577c40 <main_arena>, bytes=bytes#entry=1600) at malloc.c:3703
#6 0x00007ffff52214eb in _int_memalign (av=0x7ffff5577c40 <main_arena>, alignment=64, bytes=<optimized out>) at malloc.c:4694
#7 0x00007ffff5226fba in _mid_memalign (address=<optimized out>, bytes=1496, alignment=<optimized out>) at malloc.c:3314
#8 __posix_memalign (memptr=0x7fffffffdad0, alignment=<optimized out>, size=1496) at malloc.c:5369
#9 0x00007ffff028e7e3 in av_malloc () from /usr/local/lib/libavutil.so.56
#10 0x00007ffff06b253b in avformat_alloc_context () from /usr/local/lib/libavformat.so.58
#11 0x00007ffff5f8b9a3 in CvCapture_FFMPEG::open(char const*) () from /usr/local/lib/libopencv_videoio.so.4.2
#12 0x00007ffff5f8e9ff in cv::cvCreateFileCapture_FFMPEG_proxy(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
from /usr/local/lib/libopencv_videoio.so.4.2
#13 0x00007ffff5f71566 in cv::StaticBackend::createCapture(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const ()
from /usr/local/lib/libopencv_videoio.so.4.2
#14 0x00007ffff5f4cc17 in cv::VideoCapture::open(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) ()
from /usr/local/lib/libopencv_videoio.so.4.2
#15 0x00007ffff5f4f595 in cv::VideoCapture::VideoCapture(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) ()
from /usr/local/lib/libopencv_videoio.so.4.2
#16 0x000055555555f9b3 in GetCamFps(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) ()
#17 0x000055555555d5df in main ()
Any idea why the second videocapture doesn't work?
Thanks.
I am trying to connect with vault using libvault library. but, i am getting segmentation fault like below
Trying ..*....
TCP_NODELAY set
Connected to vault..-...net (..*.) port 8200 (#0)
ALPN, offering http/1.1
successfully set certificate verify locations:
CAfile: /etc/ssl/certs/ca-certificates.crt
CApath: none
Thread 5 "batch" received signal SIGSEGV, Segmentation fault.
Code i have written is below
Vault::Token rootToken{"*******"};
Vault::TokenStrategy tokenStrategy{rootToken};
Vault::HttpErrorCallback httpErrorCallback = [&](std::string err) {
std::cout << err << std::endl;
};
Vault::Host host{"vault.*****.***-**.***.***.net"};
Vault:: Port port{"8200"};
//Vault:: ConnectTimeout timeout{10000};
Vault::Config config = Vault::ConfigBuilder().withDebug(true).withTlsEnabled(true).withHost(host).withPort(port).build();
Vault::Client vaultClient{config, tokenStrategy, httpErrorCallback};
Vault::SecretMount mount{"/****/*****/*****"};
Vault::KeyValue kv{vaultClient,mount};
Vault::Path key{"**/***/***"};
std::cout<<"vault check initial<<std::endl;
auto response = kv.read(key);
if (response) {
std::cout<<"vault check"<<std::endl;
std::cout << response.value() << std::endl;
} else {
std::cout << "Unable to read secrets" << std::endl;
}
exception is during reading the kv.read(key)
Below is the stacktrace ...
(gdb) bt
#0 0x0000000000000009 in ?? ()
#1 0x00000000011687be in ossl_connect_step1 (conn=conn#entry=0x7fffe40288a0, sockindex=sockindex#entry=0)
at /3rdparty/curl/lib/vtls/openssl.c:2605
#2 0x000000000116acde in ossl_connect_common (conn=0x7fffe40288a0, sockindex=0, nonblocking=nonblocking#entry=true,
done=0x7ffff488e17d) at /3rdparty/curl/lib/vtls/openssl.c:3457
#3 0x000000000116aed2 in Curl_ossl_connect_nonblocking (conn=<optimized out>, sockindex=<optimized out>,
done=<optimized out>) at /3rdparty/curl/lib/vtls/openssl.c:3543
#4 0x0000000001141f4c in Curl_ssl_connect_nonblocking (conn=conn#entry=0x7fffe40288a0, sockindex=sockindex#entry=0,
done=done#entry=0x7ffff488e17d) at /3rdparty/curl/lib/vtls/vtls.c:275
#5 0x0000000001151cdb in https_connecting (conn=conn#entry=0x7fffe40288a0, done=done#entry=0x7ffff488e17d)
at /3rdparty/curl/lib/http.c:1507
#6 0x000000000115349e in Curl_http_connect (conn=0x7fffe40288a0, done=0x7ffff488e17d)
at /3rdparty/curl/lib/http.c:1436
#7 0x000000000113d346 in Curl_protocol_connect (conn=0x7fffe40288a0, protocol_done=protocol_done#entry=0x7ffff488e17d)
at /3rdparty/curl/lib/url.c:1647
#8 0x000000000112dfd7 in multi_runsingle (multi=multi#entry=0x7fffe4007ed0, now=..., data=data#entry=0x7fffe401e2a0)
at /3rdparty/curl/lib/multi.c:1610
#9 0x000000000112ecd4 in curl_multi_perform (multi=multi#entry=0x7fffe4007ed0,
running_handles=running_handles#entry=0x7ffff488e2c0) at /3rdparty/curl/lib/multi.c:2171
#10 0x00000000011256b2 in easy_transfer (multi=multi#entry=0x7fffe4007ed0)
at /3rdparty/curl/lib/easy.c:686
#11 0x0000000001125809 in easy_perform (data=0x7fffe401e2a0, events=events#entry=false)
at /3rdparty/curl/lib/easy.c:779
--Type <RET> for more, q to quit, c to continue without paging--c
#12 0x0000000001125b08 in curl_easy_perform (data=<optimized out>) at /3rdparty/curl/lib/easy.c:798
#13 0x0000000001115d93 in Vault::HttpClient::CurlWrapper::execute (this=this#entry=0x7ffff488e4a0) at /3rdparty/libvault/include/VaultClient.h:201
#14 0x0000000001114ef6 in Vault::HttpClient::executeRequest(Vault::Tiny<Vault::UrlDetail, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&, Vault::Tiny<Vault::TokenDetail, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&, Vault::Tiny<Vault::NamespaceDetail, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > const&, std::function<void (void*)> const&, std::function<curl_slist* (curl_slist*)> const&, std::function<void (std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)> const&) const (this=this#entry=0x7ffff488e920, url=..., token=..., ns=..., setupCallback=..., curlHeaderCallback=..., errorCallback=...) at /3rdparty/libvault/src/support/HttpClient.cpp:184
#15 0x0000000001114fc5 in Vault::HttpClient::get (this=this#entry=0x7ffff488e920, url=..., token=..., ns=...) at 3rdparty/libvault/src/support/HttpClient.cpp:33
#16 0x0000000001116199 in Vault::HttpConsumer::get (client=..., url=...) at /3rdparty/libvault/src/support/HttpConsumer.cpp:12
#17 0x000000000110f940 in Vault::KeyValue::read (this=this#entry=0x7ffff488e840, path=...) at /3rdparty/libvault/src/engines/KeyValue.cpp:48
With same mount and key , i am able to connect with vault using python library
I am running Cern ROOT 6.22/00 on Ubuntu 18.04. I am running a very simple code that reads data and plots a graph.
// filename.C Example of graph with SetPoint
{
g = new TGraph();
for(i=0; i<10; i++) {
g->SetPoint(i, i, i*i - 4*i + 7);
}
g->SetMarkerStyle(22);
g->Draw("ALP");
}
When I go ahead and execute the code with .x filename.C, the code works as intended. However, when I run the same command again, I get the segmentation error:
*** Break *** segmentation violation
===========================================================
There was a crash.
This is the entire stack trace of all threads:
===========================================================
#0 0x00007f7c2e7166e7 in waitpid () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007f7c2e681107 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007f7c2f2b8ed3 in TUnixSystem::StackTrace() () from /home/nick/root/lib/libCore.so.6.22
#3 0x00007f7c2f2bb9c5 in TUnixSystem::DispatchSignals(ESignals) () from /home/nick/root/lib/libCore.so.6.22
#4 <signal handler called>
#5 0x00007f7c29f24393 in (anonymous namespace)::ScalarExprEmitter::EmitScalarConversion(llvm::Value*, clang::QualType, clang::QualType, clang::SourceLocation, bool) () from /home/nick/root/lib/libCling.so
#6 0x00007f7c29f25e84 in clang::CodeGen::CodeGenFunction::EmitScalarConversion(llvm::Value*, clang::QualType, clang::QualType, clang::SourceLocation) () from /home/nick/root/lib/libCling.so
#7 0x00007f7c29eed6e0 in clang::CodeGen::CodeGenFunction::EvaluateExprAsBool(clang::Expr const*) () from /home/nick/root/lib/libCling.so
#8 0x00007f7c29d70dc3 in clang::CodeGen::CodeGenFunction::EmitForStmt(clang::ForStmt const&, llvm::ArrayRef<clang::Attr const*>) () from /home/nick/root/lib/libCling.so
#9 0x00007f7c29d6f305 in clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) () from /home/nick/root/lib/libCling.so
#10 0x00007f7c29d6f42f in clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) () from /home/nick/root/lib/libCling.so
#11 0x00007f7c29daab12 in clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) () from /home/nick/root/lib/libCling.so
#12 0x00007f7c29dc8098 in clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /home/nick/root/lib/libCling.so
#13 0x00007f7c29dea828 in clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /home/nick/root/lib/libCling.so
#14 0x00007f7c29debb05 in clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) () from /home/nick/root/lib/libCling.so
#15 0x00007f7c29dec46f in clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) () from /home/nick/root/lib/libCling.so
#16 0x00007f7c29d2edfd in clang::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) () from /home/nick/root/lib/libCling.so
#17 0x00007f7c2a07aba0 in clang::MultiplexConsumer::HandleTopLevelDecl(clang::DeclGroupRef) () from /home/nick/root/lib/libCling.so
#18 0x00007f7c29ca5aea in cling::DeclCollector::HandleTopLevelDecl(clang::DeclGroupRef) () from /home/nick/root/lib/libCling.so
#19 0x00007f7c29c72bec in cling::IncrementalParser::ParseInternal(llvm::StringRef) () from /home/nick/root/lib/libCling.so
#20 0x00007f7c29c7540c in cling::IncrementalParser::Compile(llvm::StringRef, cling::CompilationOptions const&) () from /home/nick/root/lib/libCling.so
#21 0x00007f7c29bf36ad in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) () from /home/nick/root/lib/libCling.so
#22 0x00007f7c29bf3aaa in cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) () from /home/nick/root/lib/libCling.so
#23 0x00007f7c29cb50df in cling::MetaProcessor::readInputFromFile(llvm::StringRef, cling::Value*, unsigned long, bool) () from /home/nick/root/lib/libCling.so
#24 0x00007f7c29b6e004 in TCling::ProcessLine(char const*, TInterpreter::EErrorCode*) () from /home/nick/root/lib/libCling.so
#25 0x00007f7c29b6eaa2 in TCling::ProcessLineSynch(char const*, TInterpreter::EErrorCode*) () from /home/nick/root/lib/libCling.so
#26 0x00007f7c2f15cba8 in TApplication::ExecuteFile(char const*, int*, bool) () from /home/nick/root/lib/libCore.so.6.22
#27 0x00007f7c2f15c3d0 in TApplication::ProcessLine(char const*, bool, int*) () from /home/nick/root/lib/libCore.so.6.22
#28 0x00007f7c2f6d9002 in TRint::ProcessLineNr(char const*, char const*, int*) () from /home/nick/root/lib/libRint.so.6.22
#29 0x00007f7c2f6d93f4 in TRint::HandleTermInput() () from /home/nick/root/lib/libRint.so.6.22
#30 0x00007f7c2f2bacb0 in TUnixSystem::CheckDescriptors() () from /home/nick/root/lib/libCore.so.6.22
#31 0x00007f7c2f2bc668 in TUnixSystem::DispatchOneEvent(bool) () from /home/nick/root/lib/libCore.so.6.22
#32 0x00007f7c2f1c7751 in TSystem::Run() () from /home/nick/root/lib/libCore.so.6.22
#33 0x00007f7c2f159e7f in TApplication::Run(bool) () from /home/nick/root/lib/libCore.so.6.22
#34 0x00007f7c2f6da9f1 in TRint::Run(bool) () from /home/nick/root/lib/libRint.so.6.22
#35 0x000055f5d5017a3c in main ()
===========================================================
The lines below might hint at the cause of the crash.
You may get help by asking at the ROOT forum http://root.cern.ch/forum
Only if you are really convinced it is a bug in ROOT then please submit a
report at http://root.cern.ch/bugs Please post the ENTIRE stack trace
from above as an attachment in addition to anything else
that might help us fixing this issue.
===========================================================
#5 0x00007f7c29f24393 in (anonymous namespace)::ScalarExprEmitter::EmitScalarConversion(llvm::Value*, clang::QualType, clang::QualType, clang::SourceLocation, bool) () from /home/nick/root/lib/libCling.so
#6 0x00007f7c29f25e84 in clang::CodeGen::CodeGenFunction::EmitScalarConversion(llvm::Value*, clang::QualType, clang::QualType, clang::SourceLocation) () from /home/nick/root/lib/libCling.so
#7 0x00007f7c29eed6e0 in clang::CodeGen::CodeGenFunction::EvaluateExprAsBool(clang::Expr const*) () from /home/nick/root/lib/libCling.so
#8 0x00007f7c29d70dc3 in clang::CodeGen::CodeGenFunction::EmitForStmt(clang::ForStmt const&, llvm::ArrayRef<clang::Attr const*>) () from /home/nick/root/lib/libCling.so
#9 0x00007f7c29d6f305 in clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*) () from /home/nick/root/lib/libCling.so
#10 0x00007f7c29d6f42f in clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) () from /home/nick/root/lib/libCling.so
#11 0x00007f7c29daab12 in clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) () from /home/nick/root/lib/libCling.so
#12 0x00007f7c29dc8098 in clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /home/nick/root/lib/libCling.so
#13 0x00007f7c29dea828 in clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) () from /home/nick/root/lib/libCling.so
#14 0x00007f7c29debb05 in clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) () from /home/nick/root/lib/libCling.so
#15 0x00007f7c29dec46f in clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) () from /home/nick/root/lib/libCling.so
#16 0x00007f7c29d2edfd in clang::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) () from /home/nick/root/lib/libCling.so
#17 0x00007f7c2a07aba0 in clang::MultiplexConsumer::HandleTopLevelDecl(clang::DeclGroupRef) () from /home/nick/root/lib/libCling.so
#18 0x00007f7c29ca5aea in cling::DeclCollector::HandleTopLevelDecl(clang::DeclGroupRef) () from /home/nick/root/lib/libCling.so
#19 0x00007f7c29c72bec in cling::IncrementalParser::ParseInternal(llvm::StringRef) () from /home/nick/root/lib/libCling.so
#20 0x00007f7c29c7540c in cling::IncrementalParser::Compile(llvm::StringRef, cling::CompilationOptions const&) () from /home/nick/root/lib/libCling.so
#21 0x00007f7c29bf36ad in cling::Interpreter::EvaluateInternal(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::CompilationOptions, cling::Value*, cling::Transaction**, unsigned long) () from /home/nick/root/lib/libCling.so
#22 0x00007f7c29bf3aaa in cling::Interpreter::process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, cling::Value*, cling::Transaction**, bool) () from /home/nick/root/lib/libCling.so
#23 0x00007f7c29cb50df in cling::MetaProcessor::readInputFromFile(llvm::StringRef, cling::Value*, unsigned long, bool) () from /home/nick/root/lib/libCling.so
===========================================================
I am sure it has nothing to do with my code itself, but ideas to resolve this?
I tried your code on ROOT 6.20/06 and it indeed crashed with the same segmentation errors you posted, but I am able to run your code simply by declaring the types of variables g and i:
{
TGraph* g = new TGraph();
for(int i=0; i<10; i++) {
g->SetPoint(i, i, i*i - 4*i + 7);
}
g->SetMarkerStyle(22);
g->Draw("ALP");
}
TGraph::SetPoint method can itself handle the memory allocation issue, so the code has no problem in principle, just need to be careful when declaring variables in C/C++.
I have this C++ application running on a Ubuntu Lucid 10.04.3 LTS which is crashed and the reason really escapes me.
The method which exhibits failure is this one:
void
IoLogikCommunicator::processPacket(char const* data, WORD wSize)
{
std::string message(data, wSize);
std::stringstream ss(message);
std::string token;
std::vector<std::string> tokens;
while (std::getline(ss, token, '#')) // <- crash
tokens.push_back(token);
if (tokens[0] == "SENSORS")
processSensorsPacket(tokens);
else if (tokens[0] == "SELECTOR")
processSelectorPacket(tokens);
}
According to the core dump, data content is valid and it is:
p data
$1 = 0xb7520214 "SENSORS#192.168.107.62#DI:00#ON#DI:01#ON#DI:02#ON#DI:03#OFF#DI:04#OFF#DI:05#OFF"
p wSize
$2 = 79
The content of tokens, at crash time, is ["SENSORS"], so the first element was parsed correctly.
What happens then is:
Program terminated with signal 6, Aborted.
#0 0x009de422 in __kernel_vsyscall ()
(gdb) bt
#0 0x009de422 in __kernel_vsyscall ()
#1 0x0766a651 in raise () from /lib/tls/i686/cmov/libc.so.6
#2 0x0766da82 in abort () from /lib/tls/i686/cmov/libc.so.6
#3 0x076a149d in ?? () from /lib/tls/i686/cmov/libc.so.6
#4 0x076ab591 in ?? () from /lib/tls/i686/cmov/libc.so.6
#5 0x076ae710 in ?? () from /lib/tls/i686/cmov/libc.so.6
#6 0x076aff9c in malloc () from /lib/tls/i686/cmov/libc.so.6
#7 0x0070dc07 in operator new(unsigned int) () from /usr/lib/libstdc++.so.6
#8 0x006e7d06 in std::string::_Rep::_S_create(unsigned int, unsigned int, std::allocator<char> const&) () from /usr/lib/libstdc++.so.6
#9 0x006e9f70 in std::string::_M_mutate(unsigned int, unsigned int, unsigned int) () from /usr/lib/libstdc++.so.6
#10 0x006c4274 in std::basic_istream<char, std::char_traits<char> >& std::getline<char, std::char_traits<char>, std::allocator<char> >(std::basic_istream<char, std::char_traits<char> >&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >&, char) () from /usr/lib/libstdc++.so.6
given the SIGABRT it seems that an assert() fails inside the malloc invocation, but what could be the reason? Of course, it was impossible for me to reproduce the bug: this method is invoked several times per second and the application crashed after 30 and more days of continuous running.
The very same data, then, is processed by another identical application which is hosted on another machine: that one didn't crash.
Do you have any suggestion/hint/tips/pointer?
I am trying to run blocking_udp_echo_client on MacOS X
http://www.boost.org/doc/libs/1_35_0/doc/html/boost_asio/example/echo/blocking_udp_echo_client.cpp
I run it with argument 'localhost 9000'
But the program crashes and this is the line in the source which crashes:
`udp::socket s(io_service, udp::endpoint(udp::v4(), 0));'
this is the stack trace:
#0 0x918c3e42 in __kill
#1 0x918c3e34 in kill$UNIX2003
#2 0x9193623a in raise
#3 0x91942679 in abort
#4 0x940d96f9 in __gnu_debug::_Error_formatter::_M_error
#5 0x0000e76e in
__gnu_debug::_Safe_iterator::op_base*> >,
__gnu_debug_def::list::op_base*>,
std::allocator::op_base*> > >
>::_Safe_iterator at safe_iterator.h:124
#6 0x00014729 in boost::asio::detail::hash_map::op_base*>::bucket_type::bucket_type
at hash_map.hpp:277
#7 0x00019e97 in std::_Construct::op_base*>::bucket_type,
boost::asio::detail::hash_map::op_base*>::bucket_type> at
stl_construct.h:81
#8 0x0001a457 in
std::__uninitialized_fill_n_aux::op_base*>::bucket_type*,
__gnu_norm::vector::op_base*>::bucket_type,
std::allocator::op_base*>::bucket_type> >
>, unsigned long, boost::asio::detail::hash_map::op_base*>::bucket_type> at
stl_uninitialized.h:194
#9 0x0001a4e1 in
std::uninitialized_fill_n::op_base*>::bucket_type*,
__gnu_norm::vector::op_base*>::bucket_type,
std::allocator::op_base*>::bucket_type> >
>, unsigned long, boost::asio::detail::hash_map::op_base*>::bucket_type> at
stl_uninitialized.h:218
#10 0x0001a509 in
std::__uninitialized_fill_n_a::op_base*>::bucket_type*,
__gnu_norm::vector::op_base*>::bucket_type,
std::allocator::op_base*>::bucket_type> >
>, unsigned long, boost::asio::detail::hash_map::op_base*>::bucket_type,
boost::asio::detail::hash_map::op_base*>::bucket_type> at
stl_uninitialized.h:310
#11 0x0001aa34 in
__gnu_norm::vector::op_base*>::bucket_type,
std::allocator::op_base*>::bucket_type>
>::_M_fill_insert at vector.tcc:365
#12 0x0001acda in
__gnu_norm::vector::op_base*>::bucket_type,
std::allocator::op_base*>::bucket_type>
>::insert at stl_vector.h:658
#13 0x0001ad81 in
__gnu_norm::vector::op_base*>::bucket_type,
std::allocator::op_base*>::bucket_type>
>::resize at stl_vector.h:427
#14 0x0001ae3a in
__gnu_debug_def::vector::op_base*>::bucket_type,
std::allocator::op_base*>::bucket_type>
>::resize at vector:169
#15 0x0001b7be in boost::asio::detail::hash_map::op_base*>::rehash at
hash_map.hpp:221
#16 0x0001bbeb in boost::asio::detail::hash_map::op_base*>::hash_map at
hash_map.hpp:67
#17 0x0001bc74 in
boost::asio::detail::reactor_op_queue::reactor_op_queue at
reactor_op_queue.hpp:42
#18 0x0001bd24 in
boost::asio::detail::kqueue_reactor::kqueue_reactor at
kqueue_reactor.hpp:86
#19 0x0001c000 in
boost::asio::detail::service_registry::use_service
> at service_registry.hpp:109
#20 0x0001c14d in
boost::asio::use_service >
at io_service.ipp:195
#21 0x0001c26d in
boost::asio::detail::reactive_socket_service >::reactive_socket_service
at reactive_socket_service.hpp:111
#22 0x0001c344 in
boost::asio::detail::service_registry::use_service > > at
service_registry.hpp:109
#23 0x0001c491 in
boost::asio::use_service > > at io_service.ipp:195
#24 0x0001c4d5 in
boost::asio::datagram_socket_service::datagram_socket_service
at datagram_socket_service.hpp:95
#25 0x0001c59e in
boost::asio::detail::service_registry::use_service
> at service_registry.hpp:109
#26 0x0001c6eb in
boost::asio::use_service
> at io_service.ipp:195
#27 0x0001c711 in
boost::asio::basic_io_object
>::basic_io_object at basic_io_object.hpp:72
#28 0x0001c783 in boost::asio::basic_socket
>::basic_socket at basic_socket.hpp:108
#29 0x0001c865 in
boost::asio::basic_datagram_socket
>::basic_datagram_socket at basic_datagram_socket.hpp:107
#30 0x000027bc in main at main.cpp:32
This is the gdb output:
(gdb) continue
/Developer/SDKs/MacOSX10.5.sdk/usr/include/c++/4.0.0/debug/safe_iterator.h:127:
error: attempt to copy-construct an iterator from a singular iterator.
Objects involved in the operation:
iterator "this" # 0x0x100420 {
type = N11__gnu_debug14_Safe_iteratorIN10__gnu_norm14_List_iteratorISt4pairIiPN5boost4asio6detail16reactor_op_queueIiE7op_baseEEEEN15__gnu_debug_def4listISB_SaISB_EEEEE
(mutable iterator);
state = singular;
}
iterator "other" # 0x0xbfffe8a4 {
type = N11__gnu_debug14_Safe_iteratorIN10__gnu_norm14_List_iteratorISt4pairIiPN5boost4asio6detail16reactor_op_queueIiE7op_baseEEEEN15__gnu_debug_def4listISB_SaISB_EEEEE
(mutable iterator);
state = singular;
}
Program received signal: “SIGABRT”.
(gdb) continue
Program received signal: “?”.
Does someone has any idea why this example does not work on mac osx?
Thank you.
Looks like a bug in the boost::asio library. Here is the corresponding bug report.