freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft-devel] longjmp issue 1


From: Werner LEMBERG
Subject: [ft-devel] longjmp issue 1
Date: Sun, 07 Dec 2014 11:31:03 +0100 (CET)

Folks,


I tried to apply the attached patch so that it is possible to set a
breakpoint at `FT_Throw' while doing OTF validation[*], however, I
always get segfaults with ftvalid, and I don't know why.

Anyone who has an idea what's going on?  I'm using gcc 4.7.2 on a
GNU/Linux box, in case this is of importance.  And please don't answer
with `longjmp is evil'...

I've also attached `Roboto-Thin.ttf', together with the output of
valgrind (current SVN version) applied to a `ftvalid' binary created
with `make devel; make' of current git.


    Werner


[*] Reason is that currently `ftvalid' simply says `Roboto-Thin.ttf
    is invalid', without showing the error code.  In this particular
    case it's an invalid glyph ID.
diff --git a/include/internal/ftvalid.h b/include/internal/ftvalid.h
index 12ad036..5b06e8b 100644
--- a/include/internal/ftvalid.h
+++ b/include/internal/ftvalid.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType validation support (specification).                         */
 /*                                                                         */
-/*  Copyright 2004, 2013 by                                                */
+/*  Copyright 2004, 2013, 2014 by                                          */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -126,31 +126,28 @@ FT_BEGIN_HEADER
   /* Calls ft_validate_error.  Assumes that the `valid' local variable */
   /* holds a pointer to the current validator object.                  */
   /*                                                                   */
-  /* Use preprocessor prescan to pass FT_ERR_PREFIX.                   */
-  /*                                                                   */
-#define FT_INVALID( _prefix, _error )  FT_INVALID_( _prefix, _error )
-#define FT_INVALID_( _prefix, _error ) \
-          ft_validator_error( valid, _prefix ## _error )
+#define FT_INVALID( _error ) \
+          ft_validator_error( FT_VALIDATOR( valid ), FT_THROW( _error ) )
 
   /* called when a broken table is detected */
 #define FT_INVALID_TOO_SHORT \
-          FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
+          FT_INVALID( Invalid_Table )
 
   /* called when an invalid offset is detected */
 #define FT_INVALID_OFFSET \
-          FT_INVALID( FT_ERR_PREFIX, Invalid_Offset )
+          FT_INVALID( Invalid_Offset )
 
   /* called when an invalid format/value is detected */
 #define FT_INVALID_FORMAT \
-          FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
+          FT_INVALID( Invalid_Table )
 
   /* called when an invalid glyph index is detected */
 #define FT_INVALID_GLYPH_ID \
-          FT_INVALID( FT_ERR_PREFIX, Invalid_Glyph_Index )
+          FT_INVALID( Invalid_Glyph_Index )
 
   /* called when an invalid field value is detected */
 #define FT_INVALID_DATA \
-          FT_INVALID( FT_ERR_PREFIX, Invalid_Table )
+          FT_INVALID( Invalid_Table )
 
 
 FT_END_HEADER

Attachment: Roboto-Thin.ttf
Description: Binary data

==22952== Memcheck, a memory error detector
==22952== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==22952== Using Valgrind-3.11.0.SVN and LibVEX; rerun with -h for copyright info
==22952== Command: /home/wl/git/freetype/freetype2-demos.compiled/ftvalid 
Roboto-Thin.ttf
==22952== 
==22952== Conditional jump or move depends on uninitialised value(s)
==22952==    at 0x4183CAA: longjmp (in /lib/libc-2.17.so)
==22952==    by 0x8053897: ft_validator_error (ftobjs.c:132)
==22952==    by 0x80EE543: otv_SingleSubst_validate (otvgsub.c:101)
==22952==    by 0x80E819D: otv_Lookup_validate (otvcommn.c:374)
==22952==    by 0x80E8351: otv_LookupList_validate (otvcommn.c:403)
==22952==    by 0x80EFAD9: otv_GSUB_validate (otvgsub.c:574)
==22952==    by 0x80F285E: otv_validate (otvmod.c:174)
==22952==    by 0x80612F9: FT_OpenType_Validate (ftotval.c:60)
==22952==    by 0x804EED9: run_ot_validator (ftvalid.c:572)
==22952==    by 0x804F62A: main (ftvalid.c:883)
==22952== 
==22952== Conditional jump or move depends on uninitialised value(s)
==22952==    at 0x4184135: sigprocmask (in /lib/libc-2.17.so)
==22952==    by 0x4183CDA: longjmp (in /lib/libc-2.17.so)
==22952==    by 0x8053897: ft_validator_error (ftobjs.c:132)
==22952==    by 0x80EE543: otv_SingleSubst_validate (otvgsub.c:101)
==22952==    by 0x80E819D: otv_Lookup_validate (otvcommn.c:374)
==22952==    by 0x80E8351: otv_LookupList_validate (otvcommn.c:403)
==22952==    by 0x80EFAD9: otv_GSUB_validate (otvgsub.c:574)
==22952==    by 0x80F285E: otv_validate (otvmod.c:174)
==22952==    by 0x80612F9: FT_OpenType_Validate (ftotval.c:60)
==22952==    by 0x804EED9: run_ot_validator (ftvalid.c:572)
==22952==    by 0x804F62A: main (ftvalid.c:883)
==22952== 
==22952== Syscall param rt_sigprocmask(set) points to uninitialised byte(s)
==22952==    at 0x418415B: sigprocmask (in /lib/libc-2.17.so)
==22952==    by 0x4183CDA: longjmp (in /lib/libc-2.17.so)
==22952==    by 0x8053897: ft_validator_error (ftobjs.c:132)
==22952==    by 0x80EE543: otv_SingleSubst_validate (otvgsub.c:101)
==22952==    by 0x80E819D: otv_Lookup_validate (otvcommn.c:374)
==22952==    by 0x80E8351: otv_LookupList_validate (otvcommn.c:403)
==22952==    by 0x80EFAD9: otv_GSUB_validate (otvgsub.c:574)
==22952==    by 0x80F285E: otv_validate (otvmod.c:174)
==22952==    by 0x80612F9: FT_OpenType_Validate (ftotval.c:60)
==22952==    by 0x804EED9: run_ot_validator (ftvalid.c:572)
==22952==    by 0x804F62A: main (ftvalid.c:883)
==22952==  Address 0xbeff0a38 is on thread 1's stack
==22952==  in frame #6, created by otv_GSUB_validate (otvgsub.c:549)
==22952== 
==22952== Warning: client switching stacks?  SP change: 0xbeff08fc --> 
0x86f2e31a
==22952==          to suppress, use: --max-stackframe=940320226 or greater
==22952== Use of uninitialised value of size 4
==22952==    at 0x4183D09: __longjmp (in /lib/libc-2.17.so)
==22952==    by 0x80F285E: otv_validate (otvmod.c:174)
==22952==    by 0x80612F9: FT_OpenType_Validate (ftotval.c:60)
==22952==    by 0x804EED9: run_ot_validator (ftvalid.c:572)
==22952==    by 0x804F62A: main (ftvalid.c:883)
==22952== 
==22952== Jump to the invalid address stated on the next line
==22952==    at 0xCF6E488: ???
==22952==    by 0x80F285E: otv_validate (otvmod.c:174)
==22952==    by 0x80612F9: FT_OpenType_Validate (ftotval.c:60)
==22952==    by 0x804EED9: run_ot_validator (ftvalid.c:572)
==22952==    by 0x804F62A: main (ftvalid.c:883)
==22952==  Address 0xcf6e488 is not stack'd, malloc'd or (recently) free'd
==22952== 
==22952== 
==22952== Process terminating with default action of signal 11 (SIGSEGV)
==22952==  Access not within mapped region at address 0xCF6E488
==22952==    at 0xCF6E488: ???
==22952==  If you believe this happened as a result of a stack
==22952==  overflow in your program's main thread (unlikely but
==22952==  possible), you can try to increase the size of the
==22952==  main thread stack using the --main-stacksize= flag.
==22952==  The main thread stack size used in this run was 8388608.
==22952== 
==22952== Process terminating with default action of signal 11 (SIGSEGV)
==22952==  Access not within mapped region at address 0x86F2E317
==22952==    at 0x402354C: _vgnU_freeres (vg_preloaded.c:58)
==22952==  If you believe this happened as a result of a stack
==22952==  overflow in your program's main thread (unlikely but
==22952==  possible), you can try to increase the size of the
==22952==  main thread stack using the --main-stacksize= flag.
==22952==  The main thread stack size used in this run was 8388608.
==22952== 
==22952== HEAP SUMMARY:
==22952==     in use at exit: 66,444 bytes in 67 blocks
==22952==   total heap usage: 95 allocs, 28 frees, 67,516 bytes allocated
==22952== 
==22952== LEAK SUMMARY:
==22952==    definitely lost: 0 bytes in 0 blocks
==22952==    indirectly lost: 0 bytes in 0 blocks
==22952==      possibly lost: 0 bytes in 0 blocks
==22952==    still reachable: 66,444 bytes in 67 blocks
==22952==         suppressed: 0 bytes in 0 blocks
==22952== Rerun with --leak-check=full to see details of leaked memory
==22952== 
==22952== For counts of detected and suppressed errors, rerun with: -v
==22952== Use --track-origins=yes to see where uninitialised values come from
==22952== ERROR SUMMARY: 5 errors from 5 contexts (suppressed: 0 from 0)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]