PerlGameDev / SDL

Rehashing the old perl SDL binding on cpan.org
http://search.cpan.org/dist/SDL
GNU General Public License v2.0
81 stars 29 forks source link

SDLx::Text->write_to segfaults #282

Open dod38fr opened 9 years ago

dod38fr commented 9 years ago

Hello

A Debian user has reported a segault with SDLx::Text in Debian bug #772123.

The code that leads to segfault is

#!/usr/bin/perl
use strict;
use SDL;
use SDL::Surface;
use SDLx::App;
use SDLx::Text;

my $dt = 1/60;
my $min_t = 1/60;

my $W = 1680/2;
my $H = 1050/2;

my $wt = 0xFFFFFFFF;
my $bk = 0x000000FF;

my $app = SDLx::App->new(w=>$W, h=>$H, dt=>$dt, min_t=>$min_t);
my $fgs = SDL::Surface->new_from($app, $app->w, $app->h, $app->format->BitsPerPixel, 0, 0, 0, 0);
my $fgt = SDLx::Text->new(h_align => 'center', size => 18, color => $bk, x => $W/2, y => 18);

$app->add_show_handler(sub{
    my($delta,$app)=@_;
    print "boom?\n";
    $fgt->write_to($fgs,"segfault");
    print "no...\n";
});

$app->run();

exit(0);

Using SDL::Surface (not SDLx::Surface) with SDLx::Text is fishy, but I don't know the exact cause of the segfault.

What's your opinion ?

All the best