- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
#define _GNU_SOURCE
#include <ucontext.h>
#include <unistd.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
volatile void *retry_address = NULL;
volatile int *value = NULL;
int value_holder = 5;
#define debug_write(MESSAGE) write(1, MESSAGE, sizeof(MESSAGE) - 1)
#if defined(REG_RIP)
#define REG_IP REG_RIP
#elif defined(REG_EIP)
#define REG_IP REG_EIP
#else
#error Intel only!
#endif
void segv_handler(int signum, siginfo_t *info, void *ucontext_ptr)
{
debug_write("You forgot to allocate your memory? Let's try again.\n");
value = &value_holder;
ucontext_t *ucontext = ucontext_ptr;
ucontext->uc_mcontext.gregs[REG_IP] = (greg_t)retry_address;
}
int main()
{
__label__ retry_label;
retry_address = &&retry_label;
struct sigaction action;
memset(&action, 0, sizeof(action));
action.sa_sigaction = segv_handler;
action.sa_flags = SA_SIGINFO;
if (sigaction(SIGSEGV, &action, NULL) < 0)
{
perror("sigaction()");
}
retry_label:
debug_write("Trying to access *value...\n");
printf("The *value is %d\n", *value);
return 0;
}
К недавнему вопросу о восстановлении после SIGSEGV.
http://ideone.com/l5pWVp
on error resume next
Либу переписали так, что даже игнор падений перестал помогать?
Особенно в сочетании с тем самым хендлером, который будет пропускать все зафейленные команды... Ничто не остановит бульдозер. Разве что сторожевой пёсик прервёт всю эту вакханалию...
Та самая Toyouta Camry, которая любила разгоняться?
Теперь у нас есть практическое доказательство того, что ява не тормозит.
Новость на линукс форуме сейчас не найду.
ps
а во http://www.linux.org.ru/news/java/1109623
Кто-то минус пропустил?
З.Ы. Неужели этих полутонных няшек сначала на каком-нибудь симуляторе не тестят?
Напомнило про хабролифт из ардуины, фольги и соплей.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65077 вот что этот ваш ссаный симулинк на Си блядогенерирует, охренеть не встать. Указатели в плавучие питухи упаковывают
https://gcc.gnu.org/bugzilla/attachment.cgi?id=34777
I mean - seriously storing a pointer as FP values of the upper/lower word
of the pointer? So I suppose this is what Matlab/Simulink generate internally
and what gets compiled - thus this is machine generated?