MagickCoreGenesis(*argv, MagickFalse); hangs

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
BrianP007
Posts: 49
Joined: 2013-12-13T09:54:14-07:00
Authentication code: 6789

MagickCoreGenesis(*argv, MagickFalse); hangs

Post by BrianP007 »

Following the example in magick/im.core.demo.c and calling MagickCoreGenesis with the name of the program, the process never completes.

It appears to saturate 1 cpu/hthread, showing 12% cpu in task manager
Does the same thing with normal or back-slashes in the .exe name
does the same thing with MagicTrue | MagicFalse flag setting
shows 8,022k working set memory used in task manager, ~12% and very jagged cpu usage (not pegged at 100%)
no change in memory usage
file size of MagickCoreGenesis.hang.exe is 50054 Bytes

windows 7 /64 / pro, 32gb, sandy_bridge, quad core,
gcc (x86_64-posix-sjlj, built by strawberryperl.com project) 4.9.2
./configure run in cygwin 64 terminal,

The make check passed all 76 tests. The convert.exe that was built works fine, is much faster than the binary (~37::47 convert.exe time ratio for same file) and generates an HSL file from a 219 MB raw with the same MD5 signature.

Here is a full program which illustrates the problem:
This is the entire output:
I:\exp>c:/bin/MagickCoreGenesis.hang.exe i:/exp/raw/6s-2015.1031-254594.7360x4912.raw -d vhs
D1, *argv=c:/bin/MagickCoreGenesis.hang.exe << Terminate in task manager. Will not respond to ctrl-c
============================

Code: Select all

// 
// Test program to show MagickCoreGenesis hanging; using ~100% CPU on 1 of 4
// cores on windoz 7/64/pro/sp1
// gcc (x86_64-posix-sjlj, built by strawberryperl.com project) 4.9.2
//
// gcc -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -march=sandybridge -Id:/download/cygwin.64/download/usr/local/include/ImageMagick-6 -LD:/download/cygwin.64/download/usr/local/lib        c:/bin/bak/MagickCoreGenesis.hang.c -lMagickCore-6.Q16HDRI  -lm  -o   c:/bin/MagickCoreGenesis.hang.exe  

void parse_argv(int argc, char *argv[]);

#include "magick/MagickCore.h"
void main(int argc, char *argv[])  {
	ExceptionInfo *exception;  
	Image *image;
	ImageInfo *image_info;
printf("D1, *argv=%s\n", *argv);  fflush(stdout);


	MagickCoreGenesis(*argv, MagickFalse);  
	//MagickCoreGenesis(*argv, MagickTrue); // HANGS

// NEVER GETS HERE!

printf("D2\n");  fflush(stdout);
	exception=AcquireExceptionInfo();
printf("D3\n");  fflush(stdout);
	image_info=CloneImageInfo((ImageInfo *) NULL);
printf("D4\n");  fflush(stdout);

	parse_argv(argc, argv);  // See what the user wants. Reads RAW file 

	DestroyImage(image);
	image_info=DestroyImageInfo(image_info);
	exception=DestroyExceptionInfo(exception);
	MagickCoreTerminus();
	exit(0);  // No ERROR. Must have found target color!
}  // End Main(). 


// =============================================================================
void parse_argv(int argc, char *argv[])  {
	printf("PAV: %d args, [0]=%s\n", argc, argv[0]);
}  // End Parse_Argv().


=================================================
gcc verbose output:

Code: Select all

Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=e:/strawberry.perl/c/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.2/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-4.9.2/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-gxx-include-dir=/mingw64/x86_64-w64-mingw32/include/c++ --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --enable-sjlj-exceptions --disable-isl-version-check --disable-cloog-version-check --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/opt/build/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/opt/build/prerequisites/x86_64-w64-mingw32-static --with-mpc=/opt/build/prerequisites/x86_64-w64-mingw32-static --with-isl=/opt/build/prerequisites/x86_64-w64-mingw32-static --with-cloog=/opt/build/prerequisites/x86_64-w64-mingw32-static --enable-cloog-backend=isl --with-pkgversion='x86_64-posix-sjlj, built by strawberryperl.com project' CFLAGS='-O2 -pipe -I/opt/build/x86_64-492-posix-sjlj-rt_v402/mingw64/opt/include -I/opt/build/prerequisites/x86_64-zlib-static/include -I/opt/build/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -I/opt/build/x86_64-492-posix-sjlj-rt_v402/mingw64/opt/include -I/opt/build/prerequisites/x86_64-zlib-static/include -I/opt/build/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS= LDFLAGS='-pipe -L/opt/build/x86_64-492-posix-sjlj-rt_v402/mingw64/opt/lib -L/opt/build/prerequisites/x86_64-zlib-static/lib -L/opt/build/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 4.9.2 (x86_64-posix-sjlj, built by strawberryperl.com project) 
COLLECT_GCC_OPTIONS='-v' '-D' 'MAGICKCORE_HDRI_ENABLE=1' '-D' 'MAGICKCORE_QUANTUM_DEPTH=16' '-march=sandybridge' '-I' 'd:/download/cygwin.64/download/usr/local/include/ImageMagick-6' '-LD:/download/cygwin.64/download/usr/local/lib' '-o' 'c:/bin/MagickCoreGenesis.hang.exe'
 e:/strawberry.perl/c/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.2/cc1.exe -quiet -v -I d:/download/cygwin.64/download/usr/local/include/ImageMagick-6 -iprefix e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/ -D_REENTRANT -D MAGICKCORE_HDRI_ENABLE=1 -D MAGICKCORE_QUANTUM_DEPTH=16 c:/bin/bak/MagickCoreGenesis.hang.c -quiet -dumpbase MagickCoreGenesis.hang.c -march=sandybridge -auxbase MagickCoreGenesis.hang -version -o P:\tmp\win_temp\ccpJUVZj.s
GNU C (x86_64-posix-sjlj, built by strawberryperl.com project) version 4.9.2 (x86_64-w64-mingw32)
	compiled by GNU C version 4.8.4, GMP version 6.0.0, MPFR version 3.1.2-p9, MPC version 1.0.2
warning: MPFR header version 3.1.2-p9 differs from library version 3.1.2-p10.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "e:/strawberry.perl/c/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/4.9.2/include"
ignoring duplicate directory "e:/strawberry.perl/c/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../include"
ignoring nonexistent directory "/mingw64/include"
ignoring duplicate directory "e:/strawberry.perl/c/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/4.9.2/include-fixed"
ignoring duplicate directory "e:/strawberry.perl/c/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/include"
#include "..." search starts here:
#include <...> search starts here:
 d:/download/cygwin.64/download/usr/local/include/ImageMagick-6
 e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/include
 e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../include
 e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/include-fixed
 e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/include
End of search list.
GNU C (x86_64-posix-sjlj, built by strawberryperl.com project) version 4.9.2 (x86_64-w64-mingw32)
	compiled by GNU C version 4.8.4, GMP version 6.0.0, MPFR version 3.1.2-p9, MPC version 1.0.2
warning: MPFR header version 3.1.2-p9 differs from library version 3.1.2-p10.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 29d43b2ed4b5875a18aac5a2bbcc837d
COLLECT_GCC_OPTIONS='-v' '-D' 'MAGICKCORE_HDRI_ENABLE=1' '-D' 'MAGICKCORE_QUANTUM_DEPTH=16' '-march=sandybridge' '-I' 'd:/download/cygwin.64/download/usr/local/include/ImageMagick-6' '-LD:/download/cygwin.64/download/usr/local/lib' '-o' 'c:/bin/MagickCoreGenesis.hang.exe'
 e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/as.exe -v -I d:/download/cygwin.64/download/usr/local/include/ImageMagick-6 -o P:\tmp\win_temp\cc5dEbxp.o P:\tmp\win_temp\ccpJUVZj.s
GNU assembler version 2.25 (x86_64-w64-mingw32) using BFD version (GNU Binutils) 2.25
COMPILER_PATH=e:/strawberry.perl/c/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.2/;e:/strawberry.perl/c/bin/../libexec/gcc/;e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/;e:/strawberry.perl/c/bin/../lib/gcc/;e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/;e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../lib/;e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/;e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../
COLLECT_GCC_OPTIONS='-v' '-D' 'MAGICKCORE_HDRI_ENABLE=1' '-D' 'MAGICKCORE_QUANTUM_DEPTH=16' '-march=sandybridge' '-I' 'd:/download/cygwin.64/download/usr/local/include/ImageMagick-6' '-LD:/download/cygwin.64/download/usr/local/lib' '-o' 'c:/bin/MagickCoreGenesis.hang.exe'
 e:/strawberry.perl/c/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.2/collect2.exe -plugin e:/strawberry.perl/c/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.2/liblto_plugin-0.dll -plugin-opt=e:/strawberry.perl/c/bin/../libexec/gcc/x86_64-w64-mingw32/4.9.2/lto-wrapper.exe -plugin-opt=-fresolution=P:\tmp\win_temp\cc56QYtC.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-liconv -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -m i386pep -Bdynamic -o c:/bin/MagickCoreGenesis.hang.exe e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/crtbegin.o -LD:/download/cygwin.64/download/usr/local/lib -Le:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2 -Le:/strawberry.perl/c/bin/../lib/gcc -Le:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib -Le:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../lib -Le:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib -Le:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../.. P:\tmp\win_temp\cc5dEbxp.o -lMagickCore-6.Q16HDRI -lm -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -liconv -lmingw32 -lgcc -lgcc_eh -lmoldname -lmingwex -lmsvcrt e:/strawberry.perl/c/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/crtend.o
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickCoreGenesis(*argv, MagickFalse); hangs

Post by magick »

You destroy an image that has not been initialized. Unpredictable results ensue. Initialize your image, for example, with ReadImage() and see if that fixes the problem.
BrianP007
Posts: 49
Joined: 2013-12-13T09:54:14-07:00
Authentication code: 6789

Re: MagickCoreGenesis(*argv, MagickFalse); hangs

Post by BrianP007 »

Magick,
<< You destroy an image that has not been initialized.
There is NO DESTROY ever attempted. It never gets that far.

The DESTROY() is on line 31. The crash/halt/stop/freeze bug happens on line 18, MagickCoreGenesis().
It NEVER GETS to line 31 because the crash happens in earlier code.

Is there a debug/diag code to pass to MagickCoreGenesis() to see why it is hanging???

TY,
B

===============================================================
FROM http://www.imagemagick.org/script/magick-core.php
#include ....... <magick/MagickCore.h>

int main(int argc,char **argv) {
ExceptionInfo *exception; ETC...

<SNIP>

MagickCoreGenesis(*argv,MagickTrue); <<<<< ONLY line ever attempted
<<<< HANGS HERE at MagickCoreGenesis() CRASH STOP. >>>>


exception=AcquireExceptionInfo(); << NEVER GETS HERE
NEVER GETS TO READIMAGE() CLONEIMAGE or CREATEIMAGE()
DESTROY() <<< NEVER GETS HERE
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: MagickCoreGenesis(*argv, MagickFalse); hangs

Post by magick »

Ok, your program worked for us. Try 'gdb myprogram'. Try run, wait for it to hang, then ctrl-C. Type 'bt' and it will tell you where the hang occurs.
BrianP007
Posts: 49
Joined: 2013-12-13T09:54:14-07:00
Authentication code: 6789

Re: MagickCoreGenesis(*argv, MagickFalse); hangs

Post by BrianP007 »

Magick,
C:\bin>gdb c:/bin/MagickCoreGenesis.hang.exe
GNU gdb (GDB) 7.8.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-w64-mingw32".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from c:/bin/MagickCoreGenesis.hang.exe...done.
(gdb) run
Starting program: c:\bin\MagickCoreGenesis.hang.exe
[New Thread 9860.0x1914]
During startup program exited with code 0xc000007b.
(gdb) bt
No stack.
(gdb)

[[ suspect DLL-HELL... some of the 66 dlls (??!!) needed to run may be missing. cygwin mangled Strawberry Perl and was euthanized ]]

---------------------------------
I turned the firewall and anti-virus off entirely.

Gcc is working:
C:\bin>rm c:/bin/cdrc_t.exe
rm: c:/bin/cdrc_t.exe: No such file or directory

C:\bin> gcc -Ofast -ffast-math -finline-functions -flto -m64 -march=native -funroll-loops c:/bin/count.distinct.raw.colors.c -o c:/bin/cdrc_t.exe

C:\bin>ll c:/bin/cdrc_t.exe
-rwxrwxrwx 1 user group 66013 Dec 15 12:24 c:/bin/cdrc_t.exe

C:\bin>c:/bin/cdrc_t.exe i:/exp/raw/pf-2015.0531-249465.pprgb.7360x4912.raw -d
CDRC: Read 216.913920 MB, 36.2 MP in 74 msec -> 2915 MB/s, CPU @ 3.421 GHz
CDRC: 36.152320M MemCpy in 67 msec
RS: R_Sort-> 769 ms, C_Unique-> 32 ms, total-> 802 ms
CDRC: 27645898 distinct RGBs = 76.471% in 0.944 sec

It built a program that counted the exact number of unique, uint48_t colors in a 217 MB RGB, .RAW file in < 1 second

----------------------------------

My use case is to take Photoshop, 16 bit .RAW files, do various calculations in C, and write out the result to an image file.

Current Process:
o Read file, monkey with data in C
o write .RAW file with ".${XRES}x$YRES" in the filename
o open shell to os
o run convert.exe -size 7360x4912 -depth 16 RGB:p:/br3/ac-254020.wb.gray.mlv.7360x4912.cv.p4.raw i:/exp/254020.b.png

I would like to be able to write an image in C
o Read/monkey around
o WriteImage(image_info, image); // <-= Part that doesn't work. Must limp out to shell ;(

------------------------------------------------------------------------------

The experimental cygwin I had used to do the `.configure` destroyed cpan on the essential Strawberry Perl so I had to NUKE it.

With Strawberry Perl, GCC and without cygwin (<<bahished!), is it possible to build ImageMagick on Win 7? I also have an old Intel compiler.

Wouldn't a PERL configure process work everywhere, not require an OS level KLUDGE to work? Python?

How far of a stretch is it from PerlMagick to Perl_Config->Magick? Perhaps this would overtax your staff Perl Gurus?

GCC is the leading, non-proprietary, non-ms_evil compiler for open source programs. Windows 7 still has more installs than all other OSes combined (56%). While supporting all possible OS/compiler combinations is unrealistic, supporting the Top _1_ os/compiler seems doable, Practical, reasonable, HIGHLY_DESIRABLE.

WxWidgets, for example, ships build/msw/config.gcc. They also have bcc, wat, and vc. OS2, OSX, CE, Linux and Windoz. 20 os/compiler combinations shipping.

gcc -f win7.gcc.ImageMagick.makefile <enter> [[ would you happen to have a makefile for win7/gcc lying around?? ]]

build.ImageMagick.pl <enter> [[ Intern needing a useful, MODERNIZATION project? ]]

Is it possible to cross-compile from OpenSuse. I can reboot and cross-compile if you think it will work.

Where's the Magick?? :)

B


gcc (x86_64-posix-sjlj, built by strawberryperl.com project) 4.9.2
Post Reply