std::function SIGILL_ILLOPC - c++

I got some strange crash.
I cannot reproduce it, but it keeps reporting from customer
the platform is Arm64
gcc version is 6.4
the code is quite simple:
template <typename T, typename F, typename ...Args>
Timer::registerTimerTask(T interval, F func, bool once, Args... args) {
auto t = std::chrono::duration_cast<std::chrono::nanoseconds>(interval);
auto f = [=]() mutable {func(args...);};
auto task = std::make_shared<Task>(f, t, once);
addTask(task);
}
Task::Task(std::function<void()>func, std::chrono::nanoseconds timeout, bool once=false):
mFunc(func), mTimeout(timeout), mOnce(once) {}
the code is quite simple, but on some customer's machine, it keeps crashing at constructor Task::Task, and it's SIGILL_ILLOPC
as far as I can understand, ILLOPC only happened when I have problem with cross-compiling, but this time it's not (since the same elf file works fine on others)
the stack is like:
Operating system: Linux
0.0.0 Linux 4.9.191 #1 SMP PREEMPT Mon Oct 31 06:32:31 UTC 2022 aarch64
CPU: arm64
4 CPUs
GPU: UNKNOWN
Crash reason: SIGILL / ILL_ILLOPC
Crash address: 0x7f8e50dc14
Process uptime: not available
Thread 20 (crashed)
0 myso.so!std::_Function_base::_Base_manager<Timer::registerTimerTask(T&&, F, bool, Args&& ...) [with T = std::chrono::duration<long int, std::ratio<1l, 1000l> >&; F = Impl::socket(std::__cxx11::string, std::__cxx11::string, std::shared_ptr<Listener<std::__cxx11::basic_string<char> > >)::<lambda()>; Args = {}]::<lambda()> >::_M_manager [functional : 1591 + 0x4]
x0 = 0x0000007f6c002840 x1 = 0x0000007f767f5db8
x2 = 0x0000000000000002 x3 = 0x0000007f8e50dc10
x4 = 0x0000007f6c0054c0 x5 = 0x0000007f6c002b10
x6 = 0x0000000000000000 x7 = 0x0000007f8cf633c0
x8 = 0x0000007f767f5f48 x9 = 0x003b9aca00000000
x10 = 0x0101010101010101 x11 = 0x0000000000000023
x12 = 0x00000000767f6188 x13 = 0x00000003e8000000
x14 = 0x0001ab437f192700 x15 = 0x00006e641756376a
x16 = 0x0000007f8e56a618 x17 = 0x0000007f8e4eb91c
x18 = 0x0000000000000000 x19 = 0x0000007f6c002830
x20 = 0x0000007f6c002830 x21 = 0x0000007f767f5db8
x22 = 0x0000000000000001 x23 = 0x0000007f767f6188
x24 = 0x0000007f767f6137 x25 = 0x0000000000000003
x26 = 0x0000000000800000 x27 = 0x0000000000000000
x28 = 0x0000007f8c2a36f0 fp = 0x0000007f767f5cf0
lr = 0x0000007f8e50eb0c sp = 0x0000007f767f5cf0
pc = 0x0000007f8e50dc14
Found by: given as instruction pointer in context
1 myso.so!Task::Task(std::function<void ()>, std::chrono::duration<long, std::ratio<1l, 1000000000l> >, bool) [task.h : 124 + 0x24]
x19 = 0x0000007f6c002830 x20 = 0x0000007f6c002830
x21 = 0x0000007f767f5db8 x22 = 0x0000000000000001
x23 = 0x0000007f767f6188 x24 = 0x0000007f767f6137
x25 = 0x0000000000000003 x26 = 0x0000000000800000
x27 = 0x0000000000000000 x28 = 0x0000007f8c2a36f0
fp = 0x0000007f767f5d20 sp = 0x0000007f767f5d40
pc = 0x0000007f8e50e140
Found by: call frame info
I really don't know why SIGILL would happen, and I can't find anyone with similar occasion

Related

Cannot select: t11: f64 = fpow t9, ConstantFP:f64<-1.666667e-01>

We are getting below error when we are trying to compile dpc++ code using clang++ compiler.
Error message:
fatal error: error in backend: Cannot select: t11: f64 = fpow t9, ConstantFP:f64<-1.666667e-01>
t9: f64 = fma t8, t8, t6
t8: f64,ch = CopyFromReg t0, Register:f64 %117
t7: f64 = Register %117
t8: f64,ch = CopyFromReg t0, Register:f64 %117
t7: f64 = Register %117
t6: f64 = fmul t5, t5
t5: f64,ch = CopyFromReg t0, Register:f64 %118
t4: f64 = Register %118
t5: f64,ch = CopyFromReg t0, Register:f64 %118
t4: f64 = Register %118
t10: f64 = ConstantFP<-1.666667e-01>
In function: _ZN4quda8IdEEvRNS_6_7_EELi3EEES3_
llvm-foreach:
clang-15: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler/build/bin
clang-15: note: diagnostic msg: Error generating pre-processed source(s) - no pre processable inputs.
make: *** [Makefile_all.dpct:1186: libquda.so] Error 1
Help and guidance will be appreciated!

How to debug uncaught exception core dump in C++

The application I'm working on crashed on the client machine and I have the following callstack from the core dump:
#0 SignalKill () at /MyBuildDir/lib/c/kercalls/aarch64/SignalKill.S:8
#1 0x0000000001041d2c in abort () at /MyBuildDir/lib/c/ansi/abort.c:92
#2 0x000000007b1688d0 in __gnu_cxx::__verbose_terminate_handler () at ../../../../../libstdc++-v3/libsupc++/vterminate.cc:95
#3 0x000000007b166400 in __cxxabiv1::__terminate (handler=) at ../../../../../libstdc++-v3/libsupc++/eh_terminate.cc:47
#4 0x000000007b165238 in __cxa_call_terminate (ue_header=ue_header#entry=0x109dd5f0) at ../../../../../libstdc++-v3/libsupc++/eh_call.cc:54
#5 0x000000007b165d68 in __cxxabiv1::__gxx_personality_v0 (version=, actions=6, exception_class=, ue_header=0x109dd5f0, context=0x100c3bd0) at ../../../../../libstdc++-v3/libsupc++/eh_personality.cc:676
#6 0x00000000819f66f0 in _Unwind_RaiseException_Phase2 (exc=exc#entry=0x109dd5f0, context=context#entry=0x100c3bd0) at ../../../libgcc/unwind.inc:62
#7 0x00000000819f6f30 in _Unwind_Resume (exc=0x109dd5f0) at ../../../libgcc/unwind.inc:230
#8 0x000000008052cf04 in MyClass::MyFunction(unsigned int)
...
Looking at the call stack I assume this is caused by an uncaught exception which leads to std::terminate. Unfortunately I can't reproduce this behavior on the development machine.
Can you please help me with some debugging techniques to determine which exception was thrown? MyClass::MyFunction doesn't have any throw, but it uses several std:: types. May I assume the throw was somehow inlined in MyClass::MyFunction considering the next frame in the call stack is _Unwind_Resume? May I exclude throw during stack unwinding(double throw)?
EDIT 1:
The executable was compiled with GCC 5.4.0 and the runtime is libstdc++.so.6.0.21
EDIT 2: values on frame 7
(gdb) info locals
this_context = {reg = {0x100c3760, 0x100c3768, 0x100c3770, 0x100c3778, 0x0 <repeats 15 times>, 0x100c3780, 0x100c3788, 0x100c3790, 0x100c3798, 0x100c37a0, 0x100c37a8, 0x100c37b0, 0x100c37b8, 0x100c37c0, 0x100c37c8, 0x100c3750, 0x100c3758, 0x0 <repeats 41 times>,
0x100c37d0, 0x100c37d8, 0x100c37e0, 0x100c37e8, 0x100c37f0, 0x100c37f8, 0x100c3800, 0x100c3808, 0x0 <repeats 18 times>}, cfa = 0x100c3f90, ra = 0x8052cf04 <MyClass::MyFunction(unsigned int)+860>, lsda = 0x0, bases = {tbase = 0x0, dbase = 0x0,
func = 0x819f6eb8 <_Unwind_Resume>}, flags = 4611686018427387904, version = 0, args_size = 0, by_value = '\000' <repeats 97 times>}
cur_context = {reg = {0x100c3760, 0x100c3768, 0x100c3770, 0x100c3778, 0x0 <repeats 15 times>, 0x100c3fa0, 0x100c3fa8, 0x100c3fb0, 0x100c3fb8, 0x100c3fc0, 0x100c3fc8, 0x100c3fd0, 0x100c3fd8, 0x100c3fe0, 0x100c3fe8, 0x100c3f90, 0x100c3f98, 0x0 <repeats 41 times>,
0x100c37d0, 0x100c37d8, 0x100c37e0, 0x100c37e8, 0x100c37f0, 0x100c37f8, 0x100c3800, 0x100c3808, 0x0 <repeats 18 times>}, cfa = 0x100c41b0, ra = 0x8011f384 <ClientClass::~ClientClass()+204>, lsda = 0x8229ebd2, bases = {tbase = 0x0, dbase = 0x0,
func = 0x8011f2b8 <ClientClass::~ClientClass()>}, flags = 4611686018427387904, version = 0, args_size = 0, by_value = '\000' <repeats 97 times>}
(gdb) p exc
$1 = (struct _Unwind_Exception *) 0x109dd5f0
(gdb) p *exc
Cannot access memory at address 0x109dd5f0

How do I make the canonical PROC CALIS LINEQS example work?

I'm trying out the PROC CALIS LINEQS example outlined here (it works when I use the PATH and RAM examples) using the Wheaton dataset (I've renamed the headers to match the code below) with this code:
proc calis nobs=932 data=Wheaton;
lineqs
Anomie67 = 1.0 * f_Alien67 + E1,
Powerless67 = 0.833 * f_Alien67 + E2,
Anomie71 = 1.0 * f_Alien71 + E3,
Powerless71 = 0.833 * f_Alien71 + E4,
Education = 1.0 * f_SES + E5,
SEI = lambda * f_SES + E6,
f_Alien67 = gamma1 * f_SES + D1,
f_Alien71 = gamma2 * f_SES + beta * Alien67 + D2;
std
E1 = theta1,
E2 = theta2,
E3 = theta1,
E4 = theta2,
E5 = theta3,
E6 = theta4,
D1 = psi1,
D2 = psi2,
f_SES = phi;
cov
E1 E3 = theta5,
E2 E4 = theta5;
run;
but I get this error:
"Predictor variable Alien67 in the equation with outcome variable f_Alien71 is neither a manifest, an F, an E, nor a D variable."
What am I doing wrong?
okay, I found the error - I had to consult page 450 of the SAS OnlineDoc™: Version 8 to find the solution which is basically to change this line of code:
f_Alien71 = gamma2 * f_SES + beta * Alien67 + D2;
to
f_Alien71 = gamma2 * f_SES + beta * f_Alien67 + D2;
I got a clue when I was reading page 450 because V5 in the book which corresponds to SEI in the code was using F3 (which was f_SES) as an input and then I noticed that the input to F2 in the book (which was f_Alien71 in the code) was F1 (which was f_Alien67 in the code) and I found that there was a mismatch.

minidump using google breakpad fails to show line number where the application gets the crash

I got minidump file for my application on a crash. But it is not giving me details like function name and line number. Output is as follows
Operating system: Linux
0.0.0 Linux 3.3.8-2.2 #1 SMP Thu May 12 13:30:26 UTC 2016 mips
CPU: mips
2 CPUs
Crash reason: SIGSEGV
Crash address: 0x0
Process uptime: not available
Thread 0 (crashed)
0 breakpad_test + 0x3a8c
gp = 0x0000000000433490 sp = 0x000000007fd53c88
fp = 0x000000007fd53c88 ra = 0x0000000000403a7c
pc = 0x0000000000403a8c s0 = 0x000000000042c020
s1 = 0x000000007fd53ce0 s2 = 0x0000000000000000
s3 = 0x0000000000510cc8 s4 = 0x00000000004f8008
s5 = 0x0000000000510d08 s6 = 0x0000000000000000
s7 = 0x00000000004eac50
Found by: given as instruction pointer in context
1 breakpad_test + 0x3c70
sp = 0x000000007fd53cb0 fp = 0x000000007fd53cb0
ra = 0x0000000000403c78 pc = 0x0000000000403c70
Found by: stack scanning
2 libc-2.19.so + 0x1ba70
sp = 0x000000007fd53d08 fp = 0x000000007fd53d08
ra = 0x0000000076d5da78 pc = 0x0000000076d5da70
Found by: stack scanning
3 libpthread-2.19.so + 0x3e18
sp = 0x000000007fd53d1c fp = 0x000000007fd53d18
ra = 0x0000000076ee7e20 pc = 0x0000000076ee7e18
Found by: stack scanning
4 ld-2.19.so + 0x1140
sp = 0x000000007fd53dd0 fp = 0x000000007fd53de4
ra = 0x000000007710d148 pc = 0x000000007710d140
Found by: stack scanning
Loaded modules:
0x00400000 - 0x0041afff breakpad_test ??? (main) (WARNING: No symbols, breakpad_test, 000000000000000000000000000000000)
0x76d42000 - 0x76ee1fff libc-2.19.so ??? (WARNING: No symbols, libc-2.19.so, B5374A28E4B2C3C877040AFB9B789B840)
0x76ee4000 - 0x76f0ffff libpthread-2.19.so ??? (WARNING: No symbols, libpthread-2.19.so, DAE5F3C6A7ED15218C085E10F0DDFFD50)
0x76f12000 - 0x76f51fff libgcc_s.so.1 ???
0x76f52000 - 0x76feafff libm-2.19.so ???
0x76fec000 - 0x77103fff libstdc++.so.6.0.19 ???
0x7710c000 - 0x77130fff ld-2.19.so ??? (WARNING: No symbols, ld-2.19.so, 844E9AC8CBD82909F65336ED3619228F0)
These are the steps i am using to see the output of dump
dump_syms ~/test/breakpad_test ~/test/ > breakpad_test.sym
head -n1 breakpad_test.sym
mkdir -p ./symbols/breakpad_test/6B504121E11042222534D706EFF02E490
mv breakpad_test.sym ./symbols/breakpad_test/6B504121E11042222534D706EFF02E490/
minidump_stackwalk 521a04eb-9a79-03d7-4aa11cee-55c2136e.dmp ./symbols/ > walkthru
Am I doing anything wrong?

extract data from txt file using regexp in matlab

I need to extract some info from a txt file which looks like this using regexp:
##FileName = disp_20120803_064635_1
#Plane1
x1 = 10008 x2= -9991 x3= -9991
y1 = 137 y2 = 10 y3 = 158
z1= 844 z2= 779 z3 = 700
#Plane2
x1 = -16 x2= 193 x3= 320
y1 = -4472 y2 = -556 y3 = 5143
z1= 3215 z2= -1309 z3 = 370
#Plane3
x1 = -8145 x2= 5387 x3= 8070
y1 = -4808 y2 = 7643 y3 = 3051
z1= 4212 z2= 4120 z3 = -4176
##end
I want to extract the file name by the following code:
buffer = fileread('test.txt') ;
pattern = '##FileName\s=\s+(\w+?\d+)';
tokens = regexp(buffer, pattern, 'tokens');
fileName = [tokens{:}]
But the result is just disp_20120803 which is not the complete file name?
Any help?
Use this pattern instead:
pattern = '##FileName\s=\s+(\w+)';
Edit:
I don't know matlab syntax but you can use the following regex to capture the variables name and their values:
pattern = '([xyz][123])\s*=\s*(-?\d+)'
The variable name is in group 1 and its value in group 2.