Re: [Patch] gutenprint53+usb crashes with libusb-1.0.25

Benjamin Berg <[email protected]>
Newsgroups gmane.linux.printing.gimp-print.devel
Message-ID <[email protected]>
Hi,

On Wed, 2022-02-23 at 09:34 +0100, Zdenek Dohnal wrote:
> thank you for looking into the issue!
> 
> On 2/22/22 19:00, Solomon Peachy wrote:
> > On Tue, Feb 22, 2022 at 07:55:18AM +0100, Zdenek Dohnal wrote:
> > > there were changes in libusb 1.0.25 which is in Fedora 36 - f.e. default USB
> > > context is not initialized unless you specifically pass NULL into
> > > `libusb_init()` - gutenprint53+usb backend actually depended on this hidden
> > > behavior, because it passes its own context address into `libusb_init()`
> > > instead of NULL. So the change causes the backend to crash if you run it:
> > Yikes!
> > 
> > > According libusb maintainer, Ben Berg, the backend can work with the default
> > > USB context and he prepared the patch for it (the file is attached). I was
> > > able to verify the patch fixes the crash, but I don't have a device
> > > supported by gutenprint itself, so I couldn't do an additional sanity
> > > testing. The patch looks good to me though.
> > Will this work for multi-threaded stuff where there could conceivably be
> > multiple contexts in use?  That's not being exercised in the current
> > gutenprint code but some of the stuff I have cooking will change that.
> 
> Ben, would you mind looking into it? IMO we probably cannot use a 
> default USB context for multi-threading...
> 
> In such case, IMO we can init the default context just for the 
> print_help() scope and close it after we're done with it.
> 
> You can join us in discussion on the bug if you are able as well [1], 
> I've pinged Robert there as well, because I didn't know your email for 
> bugzilla...

I am already subscribed to that bug. :)

About multi-threading. libusb itself is thread-safe, so, it depends on
what exactly the needs are. Having separate contexts means that you can
choose to only process events on one of them at a time. This avoids any
issue where one thread is suddenly processing events for another (i.e.
it is undefined which thread executes the callbacks for asynchronous
transfers).

But, e.g. just doing an enumeration from a different thread using the
same context should be completely fine.

Benjamin

> > 
> > > Would you mind adding the patch to the project if it looks good for you?
> > I won't be able to physically test any of this until this coming weekend
> > (out of town and while I have remote access everything pertinent is
> > turned off) but when I'm back, I'll be able to at least it doesn't
> > introduce any regressions on F34 & F35.
> Ok, Ben reverted the libusb change for now to do not block Fedora 36 
> beta, so IMO after weekend is fine :) .
> > 
> >   - Solomon
> 
> 
> [1] https://bugzilla.redhat.com/show_bug.cgi?id=2055504
>

_______________________________________________
Gimp-print-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gimp-print-devel
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEED2NO4vMS33W8E4AFq6ZWhpmFY3AFAmIV/XEACgkQq6ZWhpmF
Y3DndRAAiAv03dcrV7WlHcHVkdy3lnElm4RaBXlByxUJovIdIw1LnRHyUhluOGBJ
lgdELDNgQLRl7erEZPtBhwfu60H/e7d397ZctqtuydF0RXAIQw5F8qkQL0bRDDnW
ieCe85LbNsm50ddL9ipPvbj8fPib6dks57QKRYzm2JcxRkgH21dPDuR1p7yjO+Ih
iwkJ0xwgGZRLQUdPfjgI3KnKd7jUz+GQVzVN9bc4I+OVyuOqX1RIU+ZshFq8Cq+w
ePOdpNqwCNtwMJK7CaTLq6vVBEesPI3iKla82zgI5S7EPTLonPRdrtRTl+5nzmjV
GWcFssjHBymmSuK6N9cnhqLqmFAq15gU1KBJx0HaO3Q/uQqC1B9NQaguFMmtbrcB
3He2e8WNsSzN8+FOEi90J/2VQfxMXTIWdJa8wLIkGHTm/g76bMrKQIdOV3g+aBTg
prDhZ9SqLNnXDCuklz3VIZXN8SxUXVDJinyRXJ5rk7kBtLpSg+5J0kvVcMKKNLsb
q9f/iWULYx/Ee8OFqqx9P9Y2p3yda6rfBzv2GFZYVkxw8xhKn4WxS7BT5QErTdKY
pGk0053JwZxnSuqmzT+Xe4RwS9haB6EJThrNTi6sa4qU0NKlqsZVFCQt3LmEVwd2
B+uI32Mod/H83SArc9Wl9scm+clloLGwV0tk7SRzw2Ptxfj9avA=
=C+pX
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.