option to trace all orc calls

used to generate the program here:

https://bugzilla.gnome.org/show_bug.cgi?id=731227
This commit is contained in:
John Cupitt 2014-06-04 18:51:53 +01:00
parent 23911afb1c
commit f1f6bde680
3 changed files with 25 additions and 52 deletions

34
TODO
View File

@ -1,37 +1,3 @@
- orc bug:
orccodemem.c sees corruption of the list it uses to track code regions
all code region allocate / free happens on the same thread
running with --vips-concurrency=1 makes no difference
can be triggered with just im_conv()
adjusting vips_vector_full() to drop the I count per pass makes no
difference
only happens with orc-0.4.19
if we use the general conv path and only codegen the vector path, we
still get the crash
removing either matrix codegen or scale+round codegen stops the crash
leaving codegen, but commenting out the final compile stops the crash
- typical crash:
==30851== Invalid write of size 4
==30851== at 0xB821D85: orc_code_chunk_free (orccodemem.c:184)
==30851== by 0xB838839: orc_code_free (orccode.c:33)
==30851== by 0xB822545: orc_program_free (orcprogram.c:175)
==30851== by 0x6508A68: vips_vector_free (vector.c:111)
==30851== by 0x6418616: conv_vector_free (im_conv.c:186)
==30851== by 0x6418668: conv_close (im_conv.c:193)
- can we use postbuild elsewhere? look at use of "preclose" / "written", etc. - can we use postbuild elsewhere? look at use of "preclose" / "written", etc.

View File

@ -50,6 +50,7 @@ typedef struct {
/* Handy for debugging. /* Handy for debugging.
*/ */
const char *name; const char *name;
char *unique_name;
/* How many resources we've used so far in this codegen. /* How many resources we've used so far in this codegen.
*/ */

View File

@ -48,8 +48,8 @@
*/ */
/* Trace all orc calls, handy for debugging. /* Trace all orc calls, handy for debugging.
*/
#define DEBUG_TRACE #define DEBUG_TRACE
*/
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
#include <config.h> #include <config.h>
@ -119,22 +119,27 @@ vips_vector_free( VipsVector *vector )
* Comment out (and live with the leak) until this is fixed. * Comment out (and live with the leak) until this is fixed.
*/ */
#ifdef DEBUG_TRACE #ifdef DEBUG_TRACE
printf( "orc_program_free( %p );\n", vector->program ); printf( "orc_program_free( %s );\n", vector->unique_name );
printf( "%s = NULL;\n", vector->unique_name );
#endif /*DEBUG_TRACE*/ #endif /*DEBUG_TRACE*/
VIPS_FREEF( orc_program_free, vector->program ); VIPS_FREEF( orc_program_free, vector->program );
#endif /*HAVE_ORC*/ #endif /*HAVE_ORC*/
VIPS_FREE( vector->unique_name );
VIPS_FREE( vector ); VIPS_FREE( vector );
} }
VipsVector * VipsVector *
vips_vector_new( const char *name, int dsize ) vips_vector_new( const char *name, int dsize )
{ {
static int vector_number = 0;
VipsVector *vector; VipsVector *vector;
int i; int i;
if( !(vector = VIPS_NEW( NULL, VipsVector )) ) if( !(vector = VIPS_NEW( NULL, VipsVector )) )
return( NULL ); return( NULL );
vector->name = name; vector->name = name;
vector->unique_name = g_strdup_printf( "p[%d]", vector_number++ );
vector->n_temp = 0; vector->n_temp = 0;
vector->n_scanline = 0; vector->n_scanline = 0;
vector->n_source = 0; vector->n_source = 0;
@ -155,7 +160,7 @@ vips_vector_new( const char *name, int dsize )
#ifdef HAVE_ORC #ifdef HAVE_ORC
vector->program = orc_program_new(); vector->program = orc_program_new();
#ifdef DEBUG_TRACE #ifdef DEBUG_TRACE
printf( "%p = orc_program_new();\n", vector->program ); printf( "%s = orc_program_new();\n", vector->unique_name );
#endif /*DEBUG_TRACE*/ #endif /*DEBUG_TRACE*/
/* We always make d1, our callers make either a single point source, or /* We always make d1, our callers make either a single point source, or
@ -164,8 +169,8 @@ vips_vector_new( const char *name, int dsize )
vector->d1 = orc_program_add_destination( vector->program, vector->d1 = orc_program_add_destination( vector->program,
dsize, "d1" ); dsize, "d1" );
#ifdef DEBUG_TRACE #ifdef DEBUG_TRACE
printf( "%d = orc_program_add_destination( %p, %d, \"d1\" );\n", printf( "orc_program_add_destination( %s, %d, \"d1\" );\n",
vector->d1, vector->program, dsize ); vector->unique_name, dsize );
#endif /*DEBUG_TRACE*/ #endif /*DEBUG_TRACE*/
vector->n_destination += 1; vector->n_destination += 1;
#endif /*HAVE_ORC*/ #endif /*HAVE_ORC*/
@ -185,8 +190,8 @@ vips_vector_asm2( VipsVector *vector,
#ifdef HAVE_ORC #ifdef HAVE_ORC
#ifdef DEBUG_TRACE #ifdef DEBUG_TRACE
printf( "orc_program_append_ds_str( %p, %s, %s, %s );\n", printf( "orc_program_append_ds_str( %s, \"%s\", \"%s\", \"%s\" );\n",
vector->program, op, a, b ); vector->unique_name, op, a, b );
#endif /*DEBUG_TRACE*/ #endif /*DEBUG_TRACE*/
orc_program_append_ds_str( vector->program, op, a, b ); orc_program_append_ds_str( vector->program, op, a, b );
#endif /*HAVE_ORC*/ #endif /*HAVE_ORC*/
@ -204,8 +209,9 @@ vips_vector_asm3( VipsVector *vector,
#ifdef HAVE_ORC #ifdef HAVE_ORC
#ifdef DEBUG_TRACE #ifdef DEBUG_TRACE
printf( "orc_program_append_str( %p, %s, %s, %s, %s );\n", printf( "orc_program_append_str( %s, \"%s\", "
vector->program, op, a, b, c ); "\"%s\", \"%s\", \"%s\" );\n",
vector->unique_name, op, a, b, c );
#endif /*DEBUG_TRACE*/ #endif /*DEBUG_TRACE*/
orc_program_append_str( vector->program, op, a, b, c ); orc_program_append_str( vector->program, op, a, b, c );
#endif /*HAVE_ORC*/ #endif /*HAVE_ORC*/
@ -238,8 +244,8 @@ vips_vector_constant( VipsVector *vector, char *name, int value, int size )
if( orc_program_find_var_by_name( vector->program, name ) == -1 ) { if( orc_program_find_var_by_name( vector->program, name ) == -1 ) {
#ifdef DEBUG_TRACE #ifdef DEBUG_TRACE
printf( "orc_program_add_constant( %p, %d, %d, %s );\n", printf( "orc_program_add_constant( %s, %d, %d, \"%s\" );\n",
vector->program, size, value, name ); vector->unique_name, size, value, name );
#endif /*DEBUG_TRACE*/ #endif /*DEBUG_TRACE*/
orc_program_add_constant( vector->program, size, value, name ); orc_program_add_constant( vector->program, size, value, name );
vector->n_constant += 1; vector->n_constant += 1;
@ -258,8 +264,8 @@ vips_vector_source_name( VipsVector *vector, char *name, int size )
vector->s[vector->n_source] = var = vector->s[vector->n_source] = var =
orc_program_add_source( vector->program, size, name ); orc_program_add_source( vector->program, size, name );
#ifdef DEBUG_TRACE #ifdef DEBUG_TRACE
printf( "%d = orc_program_add_source( %p, %d, %s );\n", printf( "orc_program_add_source( %s, %d, \"%s\" );\n",
var, vector->program, size, name ); vector->unique_name, size, name );
#endif /*DEBUG_TRACE*/ #endif /*DEBUG_TRACE*/
vector->n_source += 1; vector->n_source += 1;
#else /*!HAVE_ORC*/ #else /*!HAVE_ORC*/
@ -281,8 +287,8 @@ vips_vector_source_scanline( VipsVector *vector,
var = orc_program_add_source( vector->program, size, name ); var = orc_program_add_source( vector->program, size, name );
#ifdef DEBUG_TRACE #ifdef DEBUG_TRACE
printf( "%d = orc_program_add_source( %p, %d, %s );\n", printf( "orc_program_add_source( %s, %d, \"%s\" );\n",
var, vector->program, size, name ); vector->unique_name, size, name );
#endif /*DEBUG_TRACE*/ #endif /*DEBUG_TRACE*/
vector->sl[vector->n_scanline] = var; vector->sl[vector->n_scanline] = var;
vector->line[vector->n_scanline] = line; vector->line[vector->n_scanline] = line;
@ -299,8 +305,8 @@ vips_vector_temporary( VipsVector *vector, char *name, int size )
orc_program_add_temporary( vector->program, size, name ); orc_program_add_temporary( vector->program, size, name );
#ifdef DEBUG_TRACE #ifdef DEBUG_TRACE
printf( "orc_program_add_temporary( %p, %d, %s );\n", printf( "orc_program_add_temporary( %s, %d, \"%s\" );\n",
vector->program, size, name ); vector->unique_name, size, name );
#endif /*DEBUG_TRACE*/ #endif /*DEBUG_TRACE*/
vector->n_temp += 1; vector->n_temp += 1;
#endif /*HAVE_ORC*/ #endif /*HAVE_ORC*/
@ -339,7 +345,7 @@ vips_vector_compile( VipsVector *vector )
result = orc_program_compile( vector->program ); result = orc_program_compile( vector->program );
#ifdef DEBUG_TRACE #ifdef DEBUG_TRACE
printf( "orc_program_compile( %p ) == %d\n", vector->program, result ); printf( "orc_program_compile( %s );\n", vector->unique_name );
#endif /*DEBUG_TRACE*/ #endif /*DEBUG_TRACE*/
if( !ORC_COMPILE_RESULT_IS_SUCCESSFUL( result ) ) { if( !ORC_COMPILE_RESULT_IS_SUCCESSFUL( result ) ) {
#ifdef DEBUG #ifdef DEBUG