mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-05 10:49:01 +08:00
Merge pull request #2453 from stweil/crashcode
Remove SavePixForCrash and related code
This commit is contained in:
commit
8f99880a7a
@ -65,7 +65,6 @@
|
||||
#include "environ.h" // for l_uint8
|
||||
#include "equationdetect.h" // for EquationDetect
|
||||
#include "errcode.h" // for ASSERT_HOST
|
||||
#include "globaloc.h" // for SavePixForCrash, signal_exit
|
||||
#include "helpers.h" // for IntCastRounded, chomp_string
|
||||
#include "imageio.h" // for IFF_TIFF_G4, IFF_TIFF, IFF_TIFF_G3
|
||||
#ifndef DISABLED_LEGACY_ENGINE
|
||||
@ -254,25 +253,6 @@ size_t TessBaseAPI::getOpenCLDevice(void **data) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the thresholded image to stderr as a PBM file on receipt of a
|
||||
* SIGSEGV, SIGFPE, or SIGBUS signal. (Linux/Unix only).
|
||||
*/
|
||||
void TessBaseAPI::CatchSignals() {
|
||||
#ifdef __linux__
|
||||
struct sigaction action;
|
||||
memset(&action, 0, sizeof(action));
|
||||
action.sa_handler = &signal_exit;
|
||||
action.sa_flags = SA_RESETHAND;
|
||||
sigaction(SIGSEGV, &action, nullptr);
|
||||
sigaction(SIGFPE, &action, nullptr);
|
||||
sigaction(SIGBUS, &action, nullptr);
|
||||
#else
|
||||
// Warn API users that an implementation is needed.
|
||||
tprintf("CatchSignals has no non-linux implementation!\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the input file. Needed only for training and
|
||||
* loading a UNLV zone file.
|
||||
@ -2027,7 +2007,6 @@ bool TessBaseAPI::Threshold(Pix** pix) {
|
||||
thresholder_->GetScaledEstimatedResolution(), estimated_res);
|
||||
}
|
||||
tesseract_->set_source_resolution(estimated_res);
|
||||
SavePixForCrash(estimated_res, *pix);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2124,7 +2103,6 @@ void TessBaseAPI::ClearResults() {
|
||||
delete paragraph_models_;
|
||||
paragraph_models_ = nullptr;
|
||||
}
|
||||
SavePixForCrash(0, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,12 +107,6 @@ class TESS_API TessBaseAPI {
|
||||
*/
|
||||
static size_t getOpenCLDevice(void **device);
|
||||
|
||||
/**
|
||||
* Writes the thresholded image to stderr as a PBM file on receipt of a
|
||||
* SIGSEGV, SIGFPE, or SIGBUS signal. (Linux/Unix only).
|
||||
*/
|
||||
static void CatchSignals();
|
||||
|
||||
/**
|
||||
* Set the name of the input file. Needed for training and
|
||||
* reading a UNLV zone file, and for searchable PDF output.
|
||||
|
@ -2,7 +2,6 @@
|
||||
* File: reject.cpp (Formerly reject.c)
|
||||
* Description: Rejection functions used in tessedit
|
||||
* Author: Phil Cheatle
|
||||
* Created: Wed Sep 23 16:50:21 BST 1992
|
||||
*
|
||||
* (C) Copyright 1992, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -45,12 +44,10 @@ int16_t Tesseract::safe_dict_word(const WERD_RES *werd_res) {
|
||||
#include "reject.h"
|
||||
#include "control.h"
|
||||
#include "docqual.h"
|
||||
#include "globaloc.h" // For err_exit.
|
||||
#include "helpers.h"
|
||||
|
||||
#include "tesseractclass.h"
|
||||
|
||||
|
||||
CLISTIZEH (STRING) CLISTIZE (STRING)
|
||||
|
||||
/*************************************************************************
|
||||
@ -161,7 +158,7 @@ void Tesseract::make_reject_map(WERD_RES *word, ROW *row, int16_t pass) {
|
||||
}
|
||||
} else {
|
||||
tprintf("BAD tessedit_reject_mode\n");
|
||||
err_exit();
|
||||
ASSERT_HOST("Fatal error encountered!" == nullptr);
|
||||
}
|
||||
|
||||
if (tessedit_image_border > -1)
|
||||
|
@ -74,7 +74,6 @@ const char *format, ... // special message
|
||||
case TESSLOG:
|
||||
return; //report only
|
||||
case TESSEXIT:
|
||||
//err_exit();
|
||||
case ABORT:
|
||||
#if !defined(NDEBUG)
|
||||
// Create a deliberate abnormal exit as the stack trace is more useful
|
||||
|
@ -2,7 +2,6 @@
|
||||
* File: errcode.cpp (Formerly error.c)
|
||||
* Description: Generic error handler function
|
||||
* Author: Ray Smith
|
||||
* Created: Tue May 1 16:28:39 BST 1990
|
||||
*
|
||||
* (C) Copyright 1989, Hewlett-Packard Ltd.
|
||||
** Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@ -18,64 +17,10 @@
|
||||
**********************************************************************/
|
||||
|
||||
#include "globaloc.h"
|
||||
#include <csignal>
|
||||
#ifdef __linux__
|
||||
#include <sys/syscall.h> // For SYS_gettid.
|
||||
#include <unistd.h> // For syscall itself.
|
||||
#endif
|
||||
#include "allheaders.h"
|
||||
#include "errcode.h"
|
||||
#include "tprintf.h"
|
||||
|
||||
// Size of thread-id array of pixes to keep in case of crash.
|
||||
const int kMaxNumThreadPixes = 32768;
|
||||
|
||||
static Pix* global_crash_pixes[kMaxNumThreadPixes];
|
||||
|
||||
void SavePixForCrash(int resolution, Pix* pix) {
|
||||
#ifdef __linux__
|
||||
#ifndef ANDROID
|
||||
int thread_id = syscall(SYS_gettid) % kMaxNumThreadPixes;
|
||||
#else
|
||||
int thread_id = gettid() % kMaxNumThreadPixes;
|
||||
#endif
|
||||
pixDestroy(&global_crash_pixes[thread_id]);
|
||||
if (pix != nullptr) {
|
||||
Pix* clone = pixClone(pix);
|
||||
pixSetXRes(clone, resolution);
|
||||
pixSetYRes(clone, resolution);
|
||||
global_crash_pixes[thread_id] = clone;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// CALL ONLY from a signal handler! Writes a crash image to stderr.
|
||||
void signal_exit(int signal_code) {
|
||||
tprintf("Received signal %d!\n", signal_code);
|
||||
#ifdef __linux__
|
||||
#ifndef ANDROID
|
||||
int thread_id = syscall(SYS_gettid) % kMaxNumThreadPixes;
|
||||
#else
|
||||
int thread_id = gettid() % kMaxNumThreadPixes;
|
||||
#endif
|
||||
if (global_crash_pixes[thread_id] != nullptr) {
|
||||
fprintf(stderr, "Crash caused by image with resolution %d\n",
|
||||
pixGetYRes(global_crash_pixes[thread_id]));
|
||||
fprintf(stderr, "<Cut here>\n");
|
||||
pixWriteStreamPng(stderr, global_crash_pixes[thread_id], 0.0);
|
||||
fprintf(stderr, "\n<End cut>\n");
|
||||
}
|
||||
// Raise an uncaught signal, so as to get a useful stack trace.
|
||||
raise(SIGILL);
|
||||
#else
|
||||
abort();
|
||||
#endif
|
||||
}
|
||||
|
||||
void err_exit() {
|
||||
ASSERT_HOST("Fatal error encountered!" == nullptr);
|
||||
}
|
||||
|
||||
// TODO: remove empty function?
|
||||
void set_global_loc_code(int loc_code) {
|
||||
// global_loc_code = loc_code;
|
||||
|
@ -19,14 +19,6 @@
|
||||
#ifndef GLOBALOC_H
|
||||
#define GLOBALOC_H
|
||||
|
||||
// Saves a clone of the given pix, and notes its resolution in thread-specific
|
||||
// data, so that the image can be written prior to a crash.
|
||||
struct Pix;
|
||||
void SavePixForCrash(int resolution, Pix* pix);
|
||||
|
||||
void signal_exit(int signal_code);
|
||||
|
||||
void err_exit();
|
||||
|
||||
void set_global_loc_code(int loc_code);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user