Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trouble with libjpeg on Mac #14

Closed
run4flat opened this issue Jun 7, 2014 · 5 comments
Closed

Trouble with libjpeg on Mac #14

run4flat opened this issue Jun 7, 2014 · 5 comments

Comments

@run4flat
Copy link
Contributor

run4flat commented Jun 7, 2014

I seem to vaguely recall this being a problem in the past, but then I thought it was squashed. At any rate, I get the following error when compiling the latest git on Perl 5.18 on a Mac OS X Lion that has libjpeg.

PERL_DL_NONLAZY=1 /Users/dcmertens/perl5/perlbrew/perls/perl-5.18.1-thread-multi/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
Can't load 'blib/arch/auto/Prima/Prima.bundle' for module Prima: dlopen(blib/arch/auto/Prima/Prima.bundle, 2): Symbol not found: _jpeg_resync_to_restart
  Referenced from: /Users/dcmertens/projects/Perl/Prima/blib/arch/auto/Prima/Prima.bundle
  Expected in: dynamic lookup
 at test/Tester.pl line 34.
Compilation failed in require at test/Tester.pl line 34.`
@run4flat
Copy link
Contributor Author

run4flat commented Jun 7, 2014

A terrible hack of a work-around is to delete img/codec_jpeg.c from my local repository before running perl Makefile.PL. However, that leads to a new error:

PERL_DL_NONLAZY=1 /Users/dcmertens/perl5/perlbrew/perls/perl-5.18.1-thread-multi/bin/perl "-Iblib/lib" "-Iblib/arch" test.pl
Can't load 'blib/arch/auto/Prima/Prima.bundle' for module Prima: dlopen(blib/arch/auto/Prima/Prima.bundle, 2): Symbol not found: _DGifCloseFile
  Referenced from: /Users/dcmertens/projects/Perl/Prima/blib/arch/auto/Prima/Prima.bundle
  Expected in: dynamic lookup
 at test/Tester.pl line 34.
Compilation failed in require at test/Tester.pl line 34.

@run4flat
Copy link
Contributor Author

run4flat commented Jun 7, 2014

Removing img/codec_ungif.c "fixes" that but leads to tiff troubles. Removing img/codec_tiff.c "fixes" the tiff issue. After removing all of these codec files, I can run the test suite. It passes except for the usual suspects.

@run4flat
Copy link
Contributor Author

run4flat commented Jun 7, 2014

A quick perusal through git history shows that this is a problem on previous (released) versions of Prima as well. Have I always simply removed the codec files before compiling on my Mac?

@dk
Copy link
Owner

dk commented Jun 7, 2014

That looks to me like bad linking flags or some other change in compiler suite, underscore being added to symbol names at will

@dk
Copy link
Owner

dk commented Nov 20, 2015

There's another cause that can lead to the same error: an old Prima.so is there somewhere on the system. I think I'll close the issue since there's not much happening and I can't reproduce it on my Mac emulator. Feel free to reopen it if there's anything more.

@dk dk closed this as completed Nov 20, 2015
ppisar added a commit to ppisar/Prima that referenced this issue Feb 6, 2024
t/Image/Text.t frequently aborted with "buffer overflow detected" on
i686 and s390x platforms:

    #0  0x000003fff79ae3ca in __pthread_kill_implementation () at /lib64/libc.so.6
    dk#1  0x000003fff7954460 in raise () at /lib64/libc.so.6
    dk#2  0x000003fff793449c in abort () at /lib64/libc.so.6
    dk#3  0x000003fff79a0a2a in __libc_message_impl () at /lib64/libc.so.6
    dk#4  0x000003fff7a3aadc in __fortify_fail () at /lib64/libc.so.6
    dk#5  0x000003fff7a3a368 in __chk_fail () at /lib64/libc.so.6
    dk#6  0x000003fff7a3b400 in __memset_chk () at /lib64/libc.so.6
    dk#7  0x000003fff6ea4cce in bzero
        (__len=<optimized out>, __dest=0x580d3f50ee0, __dest=<optimized out>, __len=<optimized out>)
        at /usr/include/bits/strings_fortified.h:32
    dk#8  prima_fc_fonts (array=<optimized out>, facename=0x0, encoding=0x0, retCount=0x3ffffff929c)
        at unix/fontconfig.c:610
    dk#9  0x000003fff6dbd68e in Application_fonts
        (self=2929175997600, name=0x2aa007a31e0 "", encoding=0x2aa005d19b0 "") at class/Application.c:310
    dk#10 0x000003fff6dd1234 in Image_fonts_FROMPERL (my_perl=<optimized out>, cv=<optimized out>)
        at include/generic/Image.inc:375
    dk#11 0x000003fff7c4a69a in Perl_pp_entersub () at /lib64/libperl.so.5.38
    dk#12 0x000003fff7c3a6f2 in Perl_runops_standard () at /lib64/libperl.so.5.38
    dk#13 0x000003fff7b7b994 in perl_run () at /lib64/libperl.so.5.38
    dk#14 0x000002aa000013ae in main ()

There were two issues: prima_fc_fonts(..., int *retCount) incorrectly
updated its last argument. Next, when called again, it used this wrong
argument to compute how much memory will be allocated. However, during
this computation an integer could overflow. Then not enough memory
could be allocated, and finally bzero() could be asked to zero
a memory beyond that allocation.

This patch fixes both issues.

CPAN RT#151594
ppisar added a commit to ppisar/Prima that referenced this issue Feb 6, 2024
t/Image/Text.t frequently aborted with "buffer overflow detected" on
i686 and s390x platforms:

    #0  0x000003fff79ae3ca in __pthread_kill_implementation () at /lib64/libc.so.6
    dk#1  0x000003fff7954460 in raise () at /lib64/libc.so.6
    dk#2  0x000003fff793449c in abort () at /lib64/libc.so.6
    dk#3  0x000003fff79a0a2a in __libc_message_impl () at /lib64/libc.so.6
    dk#4  0x000003fff7a3aadc in __fortify_fail () at /lib64/libc.so.6
    dk#5  0x000003fff7a3a368 in __chk_fail () at /lib64/libc.so.6
    dk#6  0x000003fff7a3b400 in __memset_chk () at /lib64/libc.so.6
    dk#7  0x000003fff6ea4cce in bzero
        (__len=<optimized out>, __dest=0x580d3f50ee0, __dest=<optimized out>, __len=<optimized out>)
        at /usr/include/bits/strings_fortified.h:32
    dk#8  prima_fc_fonts (array=<optimized out>, facename=0x0, encoding=0x0, retCount=0x3ffffff929c)
        at unix/fontconfig.c:610
    dk#9  0x000003fff6dbd68e in Application_fonts
        (self=2929175997600, name=0x2aa007a31e0 "", encoding=0x2aa005d19b0 "") at class/Application.c:310
    dk#10 0x000003fff6dd1234 in Image_fonts_FROMPERL (my_perl=<optimized out>, cv=<optimized out>)
        at include/generic/Image.inc:375
    dk#11 0x000003fff7c4a69a in Perl_pp_entersub () at /lib64/libperl.so.5.38
    dk#12 0x000003fff7c3a6f2 in Perl_runops_standard () at /lib64/libperl.so.5.38
    dk#13 0x000003fff7b7b994 in perl_run () at /lib64/libperl.so.5.38
    dk#14 0x000002aa000013ae in main ()

prima_fc_fonts(..., int *retCount) uses *retCount argument to compute
how much memory will be allocated. However, if value of this argument
is too big, during this computation an integer could overflow. Then
not enough memory could be allocated, and finally bzero() could be
asked to zero a memory beyond that allocation.

This patch fixes the overflow. Why the argument is insantely large is
not clear yet.

CPAN RT#151594
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants