Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move AVX / SSE messages to function PrintVersionInfo (crash fix)
This information is not needed for normal runs, so it is sufficient
to show it on request (like versions and OpenCL information).

This also fixes a crash caused by undefined order of global constructors:

When the global variable SIMDDetect::detector is initialized before the
global variable debug_file, the first tprintf call in simddetect.cpp
crashes because of a NULL pointer in debug_file. This was only seen when
running with a shared library (libtesseract.so).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Dec 28, 2016
1 parent 38033ce commit 534a237
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 5 additions & 0 deletions api/tesseractmain.cpp
Expand Up @@ -28,6 +28,7 @@
#include "baseapi.h"
#include "basedir.h"
#include "renderer.h"
#include "simddetect.h"
#include "strngs.h"
#include "tprintf.h"
#include "openclwrapper.h"
Expand Down Expand Up @@ -90,6 +91,10 @@ void PrintVersionInfo() {
}
}
#endif
if (SIMDDetect::IsAVXAvailable())
printf(" Found AVX\n");
if (SIMDDetect::IsSSEAvailable())
printf(" Found SSE\n");
}

void PrintUsage(const char* program) {
Expand Down
2 changes: 0 additions & 2 deletions arch/simddetect.cpp
Expand Up @@ -60,7 +60,5 @@ SIMDDetect::SIMDDetect() {
avx_available_ = (cpuInfo[2] & 0x10000000) != 0;
}
# endif
if (avx_available_) tprintf("Found AVX\n");
if (sse_available_) tprintf("Found SSE\n");
#endif // X86_BUILD
}

0 comments on commit 534a237

Please sign in to comment.