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

libvips warnings from VipsJpeg not emitted in govips #219

Closed
mrngm opened this issue Nov 4, 2021 · 11 comments · Fixed by #374
Closed

libvips warnings from VipsJpeg not emitted in govips #219

mrngm opened this issue Nov 4, 2021 · 11 comments · Fixed by #374

Comments

@mrngm
Copy link
Contributor

mrngm commented Nov 4, 2021

On an Ubuntu 20.04 machine, we run govips @ 2.7.0, using libvips from the PPA mentioned in the readme:

$ apt search libvips
libvips-dev/focal,now 8.10.5-2ubuntu1tonimelisma2 amd64 [installed]
libvips-doc/focal,now 8.10.5-2ubuntu1tonimelisma2 all [installed,automatic]
libvips-tools/focal,now 8.10.5-2ubuntu1tonimelisma2 amd64 [installed,automatic]
libvips42/focal,now 8.10.5-2ubuntu1tonimelisma2 amd64 [installed,automatic]

For a known corrupt image, vips itself emits warnings (see also this issue in libvips):

$ vips copy 7.jpg x.v

(vips:4084223): VIPS-WARNING **: 11:20:50.137: read gave 1 warnings

(vips:4084223): VIPS-WARNING **: 11:20:50.137: VipsJpeg: Corrupt JPEG data: premature end of data segment

However, when using this Go snippet, these warnings never seem to reach the Go layer:

package main

import (
        "fmt"
        "log"
        "os"
        "time"

        "github.com/davidbyttow/govips/v2/vips"
)

func main() {
        // Note: setting these _after_ vips.Startup(nil) does not make a difference
        vips.LoggingSettings(func (msgDomain string, level vips.LogLevel, msg string) {
                fmt.Printf("%v: [%v] %q: %q\n", time.Now(), level, msgDomain, msg)
        }, vips.LogLevelDebug)

        vips.Startup(nil)
        defer vips.Shutdown()

        images := []string{"7.jpg"}
        for _, v := range images {
                image, err := os.ReadFile(v)
                if err != nil {
                        log.Fatalf("error loading file %s: %v", v, err)
                }
                switch vips.DetermineImageType(image) {
                case vips.ImageTypeJPEG:
                        img, err := vips.NewImageFromBuffer(image)
                        if err != nil {
                                log.Fatalf("error loading file: %v", err)
                        }
                        _, err = img.Copy()
                        if err != nil {
                                log.Fatalf("copy fail: %v", err)
                        }
                }
        }
}

Output:

$ ./analyse-image 
2021-11-04 14:18:59.337129598 +0100 CET m=+0.010486298: [64] "govips": "vips 8.10.5 started with concurrency=1 cache_max_files=0 cache_max_mem=52428800 cache_max=100"
2021-11-04 14:18:59.34602814 +0100 CET m=+0.019384830: [64] "govips": "registered image type\u00a0loader type=pdf"
2021-11-04 14:18:59.34614863 +0100 CET m=+0.019505256: [64] "govips": "registered image type\u00a0loader type=svg"
2021-11-04 14:18:59.346191894 +0100 CET m=+0.019548521: [64] "govips": "registered image type\u00a0loader type=webp"
2021-11-04 14:18:59.346222515 +0100 CET m=+0.019579125: [64] "govips": "registered image type\u00a0loader type=heif"
2021-11-04 14:18:59.346255558 +0100 CET m=+0.019612168: [64] "govips": "registered image type\u00a0loader type=jpeg"
2021-11-04 14:18:59.346284843 +0100 CET m=+0.019641459: [64] "govips": "registered image type\u00a0loader type=magick"
2021-11-04 14:18:59.346336411 +0100 CET m=+0.019693061: [64] "govips": "registered image type\u00a0loader type=png"
2021-11-04 14:18:59.346375949 +0100 CET m=+0.019732586: [64] "govips": "registered image type\u00a0loader type=tiff"
2021-11-04 14:18:59.346544416 +0100 CET m=+0.019901056: [64] "govips": "registered image type\u00a0loader type=heif"
2021-11-04 14:18:59.346615575 +0100 CET m=+0.019972202: [64] "govips": "registered image type\u00a0loader type=gif"
2021-11-04 14:18:59.352873895 +0100 CET m=+0.026230682: [128] "govips": "created imageref 0xc00013c000"

From a bit of digging into libvips @ 8.10.5, the warning is emitted here, through some WARNMS macro (probably from some JPEG library like libjpeg-turbo).

I've also tried using govips @ 4e728fa, using LoadImageFromBuffer and supplying ImportParams.FailErrorOnError(true), but this does not show the vips warnings.

Are we missing something on the Go side, is this something in libvips that's not interceptable, or is something missing in govips C bindings?

@mrngm
Copy link
Contributor Author

mrngm commented Nov 4, 2021

This may seem related to #147, but the gist here is that we actually want to capture these warnings (although any other method of detecting 'incomplete' or 'corrupt' images would suffice as well)

@tonimelisma
Copy link
Collaborator

Hey @mrngm - thank you very much for the bug report and digging you did. The govips interface captures glib's native logging stuff, because there's a hook where govips can insert itself (so each logging message actually calls a govips function). You're right, WARNMS seems to be a libjpeg macro. I have no idea whether it's catchable and/or how host software could intercept the warnings. Some of them seem to imply data corruption, which should surely be caught by a host.

Does the vips you run from command line abort or give an exit code, or simply display the error message and continue successfully? If the latter, I would look at filing a bug with libvips.

@tonimelisma
Copy link
Collaborator

Perhaps you could dig deeper into libvips internals to see how the error is being caught there that libvips surfaces? Apparently it's not being properly logged by the glib logging facilities libvips otherwise uses? Sounds like an upstream issue.

@mrngm
Copy link
Contributor Author

mrngm commented Nov 11, 2021

Hi @tonimelisma, thanks for replying. To clarify with regards to the output of the vips command:

$ vips copy 7.jpg x.v

(vips:3573083): VIPS-WARNING **: 10:46:28.748: read gave 1 warnings

(vips:3573083): VIPS-WARNING **: 10:46:28.749: VipsJpeg: Corrupt JPEG data: premature end of data segment

$ echo $?
0

I'll have a closer look at the libvips internals, to try and uncover how these warnings get displayed. If I have found anything useful (that could be ported to govips) I'll let you know here.

@mrngm
Copy link
Contributor Author

mrngm commented Nov 15, 2021

I've recompiled libvips 8.10.5 with debugging information. A gdb backtrace gives somewhat more information, now.

user@host:/tmp/libvips-8.10.5/vips-8.10.5$ LD_PRELOAD=libvips/.libs/libvips.so.42 G_DEBUG=fatal-warnings gdb ./tools/.libs/vips
[..]
Reading symbols from ./tools/.libs/vips...
(gdb) set args copy /tmp/7.jpg /tmp/x.v
(gdb) run
Starting program: /tmp/libvips-8.10.5/vips-8.10.5/tools/.libs/vips copy /tmp/7.jpg /tmp/x.v
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffeefb7700 (LWP 1895499)]
[New Thread 0x7fffe67b6700 (LWP 1895500)]
[New Thread 0x7fffee491700 (LWP 1895501)]
[New Thread 0x7fffedc90700 (LWP 1895502)]
[New Thread 0x7fffed429700 (LWP 1895503)]
[New Thread 0x7fffecbf5700 (LWP 1895504)]
[New Thread 0x7fffe7fff700 (LWP 1895505)]
[New Thread 0x7fffe77fe700 (LWP 1895506)]
[New Thread 0x7fffe6ffd700 (LWP 1895507)]
[New Thread 0x7fffe5fb5700 (LWP 1895508)]
[Thread 0x7fffe6ffd700 (LWP 1895507) exited]
[Thread 0x7fffed429700 (LWP 1895503) exited]
[Thread 0x7fffee491700 (LWP 1895501) exited]
[Thread 0x7fffecbf5700 (LWP 1895504) exited]
[Thread 0x7fffe77fe700 (LWP 1895506) exited]
[Thread 0x7fffe7fff700 (LWP 1895505) exited]
[Thread 0x7fffe5fb5700 (LWP 1895508) exited]
[Thread 0x7fffedc90700 (LWP 1895502) exited]
[Thread 0x7fffeefb7700 (LWP 1895499) exited]
[Thread 0x7fffe67b6700 (LWP 1895500) exited]

(vips:1895449): VIPS-WARNING **: 17:10:10.046: read gave 1 warnings

Thread 1 "vips" received signal SIGTRAP, Trace/breakpoint trap.
0x00007ffff7964295 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
(gdb) bt
#0  0x00007ffff7964295 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#1  0x00007ffff7965579 in g_logv () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007ffff7965743 in g_log () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007ffff7c1ba25 in readjpeg_free (jpeg=0x7fffd8005340) at jpeg2vips.c:315
#4  readjpeg_close_cb (image=<optimized out>, jpeg=0x7fffd8005340) at jpeg2vips.c:341
#5  0x00007ffff7a49802 in g_closure_invoke () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#6  0x00007ffff7a5d814 in  () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7  0x00007ffff7a68bbe in g_signal_emit_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8  0x00007ffff7a690f3 in g_signal_emit () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#9  0x00007ffff7c417a1 in vips_object_close (object=0x555555681660) at object.c:291
#10 vips_object_dispose (gobject=0x555555681660) at object.c:1022
#11 0x00007ffff7a4ec93 in g_object_unref () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#12 0x00007ffff7bff531 in vips_foreign_load_dispose (gobject=0x5555556798e0) at foreign.c:443
#13 0x00007ffff7a4ec93 in g_object_unref () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#14 0x00007ffff7a51bf1 in g_object_set_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#15 0x00007ffff7a52764 in g_object_set () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#16 0x00007ffff7a49802 in g_closure_invoke () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#17 0x00007ffff7a5d814 in  () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#18 0x00007ffff7a68bbe in g_signal_emit_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#19 0x00007ffff7a690f3 in g_signal_emit () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#20 0x00007ffff7c417a1 in vips_object_close (object=0x555555681020) at object.c:291
#21 vips_object_dispose (gobject=0x555555681020) at object.c:1022
#22 0x00007ffff7a4ec93 in g_object_unref () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#23 0x00007ffff7c421b0 in vips_object_clear_member (argument_instance=0x555555672dc0) at object.c:901
#24 vips__object_set_member (object=object@entry=0x555555679830, pspec=pspec@entry=0x5555555c8c20, member=member@entry=0x555555679898, argument=0x0) at object.c:1098
#25 0x00007ffff7c42850 in vips_object_set_property (gobject=<optimized out>, property_id=<optimized out>, value=0x7fffffffdee0, pspec=0x5555555c8c20) at object.c:1254
#26 0x00007ffff7a51e76 in g_object_set_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#27 0x00007ffff7a52764 in g_object_set () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#28 0x00007ffff7c4061c in vips_object_dispose_argument
    (object=object@entry=0x555555679830, pspec=pspec@entry=0x5555555c8c20, argument_class=argument_class@entry=0x555555607830, argument_instance=<optimized out>, a=a@entry=0x0, b=b@entry=0x0) at object.c:927
#29 0x00007ffff7c41586 in vips_argument_map (object=object@entry=0x555555679830, fn=fn@entry=0x7ffff7c40560 <vips_object_dispose_argument>, a=a@entry=0x0, b=b@entry=0x0) at object.c:606
#30 0x00007ffff7c4172b in vips_argument_dispose_all (object=0x555555679830) at object.c:1020
#31 vips_object_dispose (gobject=0x555555679830) at object.c:1020
#32 0x00007ffff7a4ec93 in g_object_unref () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#33 0x0000555555556fb7 in main (argc=<optimized out>, argv=<optimized out>) at vips.c:732
(gdb) cont
Continuing.

(vips:1895449): VIPS-WARNING **: 17:10:33.163: VipsJpeg: Corrupt JPEG data: premature end of data segment


Thread 1 "vips" received signal SIGTRAP, Trace/breakpoint trap.
0x00007ffff7964295 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
(gdb) bt
#0  0x00007ffff7964295 in  () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#1  0x00007ffff7965579 in g_logv () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#2  0x00007ffff7965743 in g_log () at /lib/x86_64-linux-gnu/libglib-2.0.so.0
#3  0x00007ffff7c1ba47 in readjpeg_free (jpeg=0x7fffd8005340) at jpeg2vips.c:317
#4  readjpeg_close_cb (image=<optimized out>, jpeg=0x7fffd8005340) at jpeg2vips.c:341
#5  0x00007ffff7a49802 in g_closure_invoke () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#6  0x00007ffff7a5d814 in  () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7  0x00007ffff7a68bbe in g_signal_emit_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8  0x00007ffff7a690f3 in g_signal_emit () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#9  0x00007ffff7c417a1 in vips_object_close (object=0x555555681660) at object.c:291
#10 vips_object_dispose (gobject=0x555555681660) at object.c:1022
#11 0x00007ffff7a4ec93 in g_object_unref () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#12 0x00007ffff7bff531 in vips_foreign_load_dispose (gobject=0x5555556798e0) at foreign.c:443
#13 0x00007ffff7a4ec93 in g_object_unref () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#14 0x00007ffff7a51bf1 in g_object_set_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#15 0x00007ffff7a52764 in g_object_set () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#16 0x00007ffff7a49802 in g_closure_invoke () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#17 0x00007ffff7a5d814 in  () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#18 0x00007ffff7a68bbe in g_signal_emit_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#19 0x00007ffff7a690f3 in g_signal_emit () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#20 0x00007ffff7c417a1 in vips_object_close (object=0x555555681020) at object.c:291
#21 vips_object_dispose (gobject=0x555555681020) at object.c:1022
#22 0x00007ffff7a4ec93 in g_object_unref () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#23 0x00007ffff7c421b0 in vips_object_clear_member (argument_instance=0x555555672dc0) at object.c:901
#24 vips__object_set_member (object=object@entry=0x555555679830, pspec=pspec@entry=0x5555555c8c20, member=member@entry=0x555555679898, argument=0x0) at object.c:1098
#25 0x00007ffff7c42850 in vips_object_set_property (gobject=<optimized out>, property_id=<optimized out>, value=0x7fffffffdee0, pspec=0x5555555c8c20) at object.c:1254
#26 0x00007ffff7a51e76 in g_object_set_valist () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#27 0x00007ffff7a52764 in g_object_set () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#28 0x00007ffff7c4061c in vips_object_dispose_argument
    (object=object@entry=0x555555679830, pspec=pspec@entry=0x5555555c8c20, argument_class=argument_class@entry=0x555555607830, argument_instance=<optimized out>, a=a@entry=0x0, b=b@entry=0x0) at object.c:927
#29 0x00007ffff7c41586 in vips_argument_map (object=object@entry=0x555555679830, fn=fn@entry=0x7ffff7c40560 <vips_object_dispose_argument>, a=a@entry=0x0, b=b@entry=0x0) at object.c:606
#30 0x00007ffff7c4172b in vips_argument_dispose_all (object=0x555555679830) at object.c:1020
#31 vips_object_dispose (gobject=0x555555679830) at object.c:1020
#32 0x00007ffff7a4ec93 in g_object_unref () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0
#33 0x0000555555556fb7 in main (argc=<optimized out>, argv=<optimized out>) at vips.c:732

@mrngm
Copy link
Contributor Author

mrngm commented Nov 15, 2021

The warnings are emitted in readjpeg_free. Closing an image in govips eventually calls g_clear_object(image).

It seems to me that govips does not follow the same code path as vips itself does. Or g_clear_object(image) must do some internal magic that I'm not aware of... but it still does not seem to call readjpeg_free.

@tonimelisma thoughts on the above?

(edit: added code reference for readjpeg_free)

@tonimelisma
Copy link
Collaborator

Sounds like that's going pretty deep into the internals of libjpeg, but it also sounds like the ball is in our court at govips. I suppose you could take a look at the code and see if a PR could fix this? I would definitely be a fan of proper warnings.

@mrngm
Copy link
Contributor Author

mrngm commented Nov 23, 2021

I've made a start by looking how libvips describes their reference counting. The following diff in govips sets a small step in the right direction, along with a slightly adjusted test program (see further on).

diff --git a/vips/image.c b/vips/image.c
index 792b591..84bddf4 100644
--- a/vips/image.c
+++ b/vips/image.c
@@ -4,5 +4,5 @@ int has_alpha_channel(VipsImage *image) { return vips_image_hasalpha(image); }
 
 void clear_image(VipsImage **image) {
   // https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html#g-clear-object
-  if (G_IS_OBJECT(*image)) g_clear_object(image);
+  if (G_IS_OBJECT(*image)) g_object_unref(*image);
 }

Test program:

package main

import (
        "fmt"
        "log"
        "os"
        "time"

        "github.com/davidbyttow/govips/vips" // in go.mod: replace github.com/davidbyttow/govips/vips => /home/path/to/patched/govips
)

func main() {
        // Note: setting these _after_ vips.Startup(nil) does not make a difference
        vips.LoggingSettings(func(msgDomain string, level vips.LogLevel, msg string) {
                fmt.Printf("%v: [%v] %q: %q\n", time.Now(), level, msgDomain, msg)
        }, vips.LogLevelDebug)

        vips.Startup(nil)
        defer vips.Shutdown()

        images := []string{"7.jpg"}
        for _, v := range images {
                image, err := os.ReadFile(v)
                if err != nil {
                        log.Fatalf("error loading file %s: %v", v, err)
                }
                switch vips.DetermineImageType(image) {
                case vips.ImageTypeJPEG:
                        img, err := vips.NewImageFromBuffer(image)
                        if err != nil {
                                log.Fatalf("error loading file: %v", err)
                        }
                        _, err = img.Copy()
                        if err != nil {
                                log.Fatalf("copy fail: %v", err)
                        }
                        _, _, err = img.ExportJpeg(nil) // line 37
                        if err != nil {
                                log.Fatalf("export fail: %v", err)
                        }
                        img.Close()
                }
        }
}

Output:

$ ./govips-testcase 
2021-11-23 09:22:44.428435812 +0100 CET m=+0.008766042: [64] "govips": "vips 8.10.5 started with concurrency=1 cache_max_files=0 cache_max_mem=52428800 cache_max=100"
2021-11-23 09:22:44.435984992 +0100 CET m=+0.016315255: [64] "govips": "registered image type\u00a0loader type=webp"
2021-11-23 09:22:44.436158646 +0100 CET m=+0.016488832: [64] "govips": "registered image type\u00a0loader type=heif"
2021-11-23 09:22:44.43621062 +0100 CET m=+0.016540803: [64] "govips": "registered image type\u00a0loader type=jpeg"
2021-11-23 09:22:44.436251694 +0100 CET m=+0.016581874: [64] "govips": "registered image type\u00a0loader type=pdf"
2021-11-23 09:22:44.436283982 +0100 CET m=+0.016614162: [64] "govips": "registered image type\u00a0loader type=svg"
2021-11-23 09:22:44.436334953 +0100 CET m=+0.016665161: [64] "govips": "registered image type\u00a0loader type=tiff"
2021-11-23 09:22:44.436370432 +0100 CET m=+0.016700612: [64] "govips": "registered image type\u00a0loader type=heif"
2021-11-23 09:22:44.436404902 +0100 CET m=+0.016735083: [64] "govips": "registered image type\u00a0loader type=gif"
2021-11-23 09:22:44.436431373 +0100 CET m=+0.016761541: [64] "govips": "registered image type\u00a0loader type=magick"
2021-11-23 09:22:44.436455801 +0100 CET m=+0.016785972: [64] "govips": "registered image type\u00a0loader type=png"
2021-11-23 09:22:44.442200518 +0100 CET m=+0.022530726: [128] "govips": "created imageref 0xc000090040"
2021-11-23 09:22:44.758729407 +0100 CET m=+0.339059625: [16] "VIPS": "error in tile 0 x 2888"
2021/11/23 09:22:44 export fail: VipsJpeg: Corrupt JPEG data: premature end of data segment

Stack:
goroutine 1 [running]:
runtime/debug.Stack(0x7fba166be540, 0xc000128380, 0x3b)
        /usr/lib/go-1.16/src/runtime/debug/stack.go:24 +0x9f
github.com/davidbyttow/govips/vips.handleVipsError(0x535de0, 0x67bea8)
        /home/gerdriaan/scm/govips/vips/error.go:38 +0x58
github.com/davidbyttow/govips/vips.handleSaveBufferError(0x0, 0xc000000001, 0xc000131c28)
        /home/gerdriaan/scm/govips/vips/error.go:31 +0x2c
github.com/davidbyttow/govips/vips.vipsSaveToBuffer(0x2319000, 0x0, 0x1, 0x0, 0x5000000000, 0x1, 0x0, 0x0, 0x600000000, 0x8, ...)
        /home/gerdriaan/scm/govips/vips/foreign.go:403 +0xbe
github.com/davidbyttow/govips/vips.vipsSaveJPEGToBuffer(0x2319000, 0x0, 0x50, 0x1, 0x0, 0x0, 0x0, 0x707380, 0x0, 0x4670a0, ...)
        /home/gerdriaan/scm/govips/vips/foreign.go:322 +0x158
github.com/davidbyttow/govips/vips.(*ImageRef).ExportJpeg(0xc000090040, 0x0, 0x0, 0x0, 0xc000090040, 0x0, 0x0, 0xc00003e710)
        /home/gerdriaan/scm/govips/vips/image.go:651 +0xa5
main.main()
        /home/gerdriaan/scm/govips-testcase/cmd/govips-testcase/main.go:37 +0x2bc

@mrngm
Copy link
Contributor Author

mrngm commented Nov 30, 2021

Apart from the stack trace (which is added in error.go:handleVipsError()), the diff posted above seems stable enough.

make test ran fine, output of go test (without verbosity):

$ CGO_CFLAGS_ALLOW=-Xpreprocessor go test ./...
?       github.com/davidbyttow/govips/v2/examples/jpeg  [no test files]
ok      github.com/davidbyttow/govips/v2/examples/logging       0.082s [no tests to run]
?       github.com/davidbyttow/govips/v2/examples/tiff  [no test files]
ok      github.com/davidbyttow/govips/v2/vips   66.149s
ok      github.com/davidbyttow/govips/v2/vips/mem_tests 0.578s

@davidbyttow I could put this in a PR, but what would you require regarding tests and test files? There is this CC0 corrupted JPEG that I could include, and test that, on ExportJpeg it sets err to begin with "VipsJpeg: Corrupt JPEG data: bad Huffman code". Would that suffice in your opinion, or do you need anything else?

@tonimelisma
Copy link
Collaborator

@mrngm yeah I think that would be sufficient in terms of testing, it's difficult to test it otherwise. Can you submit a PR?

@mrngm
Copy link
Contributor Author

mrngm commented Apr 25, 2023

@mrngm yeah I think that would be sufficient in terms of testing, it's difficult to test it otherwise. Can you submit a PR?

I seem to have missed your reply at the time. I'll submit a PR!

mrngm pushed a commit to mrngm/govips that referenced this issue Jul 28, 2023
… libvips documentation) (davidbyttow#219), add test case for checking return errors of a known corrupted JPEG
davidbyttow pushed a commit that referenced this issue Oct 22, 2023
… libvips documentation) (#219), add test case for checking return errors of a known corrupted JPEG (#374)

Co-authored-by: Gerdriaan Mulder <[email protected]>
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

Successfully merging a pull request may close this issue.

2 participants