[prev in list] [next in list] [prev in thread] [next in thread] 

List:       libusb-devel
Subject:    [Libusb-devel] Libusb segmentation failiure with pthreads,
From:       Akos Vandra <axos88 () gmail ! com>
Date:       2011-12-20 19:52:08
Message-ID: CAHHcNocV98NeM1CH26RxrNn4Y20=jAhDjBh+rvH9M2a3UorWmA () mail ! gmail ! com
[Download RAW message or body]

Hi!

I am trying to get libusb work accross threads. I am initializing
libusb, and using it with a different context, however it segfaults.
If using fork(), it works flawlessly, even without the use of
different contexts...

Please take a look at my code, and point out what am I doing wrong. I
have both fork() and pthread version of the code, the one in use can
be chosen with the #define USE_THREADS.
The segfault is occuring when trying to open the device. Closing it on
the main thread beforehand does not help either.

The attached code is a libpcap handler, and is invoked by libpcap.
The interesting parts of the code are:

canusb_platform_finddevs - runs in the main process / thread in which
libpcap invokes my code, always runs fine.
libusb_device_handle* canusb_opendevice - runs in both the main
process / thread, and the created one to open a new libusb device
using the vid/pid and serial descriptors.

canusb_capture_process - forked process doing the data capturing
canusb_capture_thread - created thread doing the data capturing

canusb_startcapture - the function which creates the thread or task to
do the dirty work.

I have included all the code jut in case, but have highlighted the
functions that are interesting in my opinion.

http://pastebin.com/3L0HMZ1F


I am using ubuntu 10.04 64 bit, libusb-1.0.8.
akos@FM12BQ:~$ uname -a
Linux FM12BQ 2.6.35-31-generic #63-Ubuntu SMP Mon Nov 28 19:29:10 UTC
2011 x86_64 GNU/Linux
akos@FM12BQ:~$ dpkg -l | grep libusb-1
ii  libusb-1.0-0                          2:1.0.8-2
                     userspace USB programming library
ii  libusb-1.0-0-dev                      2:1.0.8-2
                     userspace USB programming library development
files


Thanks in advance,
  =C1kos Vandra

---------------------------------------------------------------------------=
---
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create =

new or port existing apps to sell to consumers worldwide. Explore the =

Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Libusb-devel mailing list
Libusb-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusb-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic