FLTK logo

[MOD] STR #3519: Sometimes Segmentation fault when printing some Unicode char's

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.bugs  ]
 
Previous Message ]New Message | Reply ]Next Message ]

[MOD] STR #3519: Sometimes Segmentation fault when printing some Unicode char's Manfred Moldenhauer Apr 02, 2019  
 
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Link: https://www.fltk.org/str.php?L3519
Version: 1.3.4


I had this problem in all versions up to 1.3.4 but until now I could not
demonstrate it in a simple program.

The problem is as follows: My application crashes with an "Segmentation
fault" when I try to print following characters:

//  U+03B9 Greek small letter Iota
//  U+207D Superscript left parenthesis
//  U+207E ... right ...
//  U+208D Subscript left parenthesis
//  U+208E ... right ...

The crash only happens when one of these chars is the last char in a
string. Unfortunately this happens often in my page formating methode when
it tries to figure out, how many words will fit in a line.

In the editor window all looks fine. Maybe it helps to know that all these
chars are of verry low width.

The debugger (ddd) message says:
Thread 1 "zk3" received signal SIGSEGV, Segmentation fault.
0x0000000000466381 in
Fl_PostScript_Graphics_Driver::transformed_draw_extra(char const*, int,
double, double, int, bool) ()
(gdb)

Sorry, for cannot supply more information.

Manfred


Link: https://www.fltk.org/str.php?L3519
Version: 1.3.4
//  FLTK printer crash demo
//
//  Crash happens with the following unicode chars:
//  U+03B9 Greek small letter Iota
//  U+207D Superscript left parenthesis
//  U+207E ... right ...
//  U+208D Subscript left parenthesis
//  U+208E ... right ...
//
//  Crash only happens when one these letters is the last one in a string.
//
//      fltk-config  -g --compile print_err.cpp


#include <FL/Fl.H>
#include <FL/Fl_Printer.H>

#include <cstring>

//const char * test_str = "\u207D";
//const char * test_str = "\u207D\n";
//const char * test_str = "abc\n";
//const char * test_str = " \u207D U+207D (8317) hochgestellte Klammer links";
const char * test_str = "\u207D";
const char * test_str2 = " U+207D (8317) hochgestellte Klammer links";

int main( int argc, char * argv[] ) {
    int     pr_w, pr_h;
    int     ml, mt, mr, mb;     // the margins (from system printer setup)
    int     x = 72; // left position in pt
    int     y = 72;
    const char * txt;
    double  dx;
    Fl_Printer * pr = new Fl_Printer();

    if( argc > 1 )
        txt = argv[1];
    else
        txt = test_str;

    if( pr->start_job( 1 ) == 0 ) {
        if( pr->printable_rect( &pr_w, &pr_h ) == 0 ) {
            pr->margins( &ml, &mt, &mr, &mb );
            pr->start_page();
            fl_font( FL_HELVETICA, 14 );
            dx = fl_width( txt );
            fprintf( stderr, "dx: %4.1f\n", dx );
            fl_draw( txt, x, y );

            if( argc == 1 ) {
                x += dx;
                dx = fl_width( test_str2 );
                fprintf( stderr, "dx: %4.1f\n", dx );
                fl_draw( test_str2, x, y );
            }

            pr->end_page();
        }
        pr->end_job();
    }
    delete pr;
    return 0;
}
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.