Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
01-22-2014, 02:06 AM
|
#1
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442
Rep:
|
Program compiles and runs on 12.0-32 compiles on 14.0-64 but won't run.
Hi: A given program compiles and runs on an x86 32-bit machine under 12.0. The same program, compiled on a 64-bit machine under 14.0-x86_64, when run on this machine, gives 'Segmentation fault'. The program is this, the line with the issue having been mark '<-- THIS ONE' (the fourth before the last line in the source):
Code:
#include <usb.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
unsigned short IDVendor= 0x1384; /*VID must be changed. */
unsigned short IDProduct= 0x8888; /*PID must be changed. */
static int usbOpenDevice(usb_dev_handle **device, int idvendor, int idproduct)
{
struct usb_bus *bus;
struct usb_device *dev;
usb_dev_handle *udh=NULL;
int retp, retm,errors;
char string[256];
usb_init();
usb_find_busses();
usb_find_devices();
for (bus = usb_busses; bus; bus = bus->next)
{
for (dev = bus->devices; dev; dev = dev->next)
{
udh=usb_open(dev);
retp = usb_get_string_simple(udh, dev->descriptor.iProduct, string, sizeof(string));
retm=usb_get_string_simple(udh, dev->descriptor.iManufacturer, string, sizeof(string));
if (retp > 0 && retm > 0)
if (idvendor==dev->descriptor.idVendor && idproduct==dev->descriptor.idProduct){ *device=udh;return errors=0;}
}
}
usb_close(udh);return errors=1;
}
int main(int argc, char **argv)
{
usb_dev_handle *d=NULL;
unsigned char buffer[3];
int i, mode, ret;
char string[256];
if(argc <2)
{
printf("give the voltage value.\n");
exit(1);
}
i=floor(atof(argv[1])*51) ;
if(i>255){printf("value must be between 0 and 5V\n"); exit(1);}
mode=0;
usb_init();
ret=usbOpenDevice(&d, IDVendor,IDProduct); <-- THIS ONE
if(ret!=0){printf("usbOpenDevice failed\n"); return 0;}
ret=usb_control_msg(d, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN, mode, i, 0, (char *)buffer, sizeof(buffer), 5000);
// printf("buffer %d \n", buffer[0]);
return 0;
}
Any known cause?
|
|
|
01-22-2014, 01:12 PM
|
#2
|
Member
Registered: Sep 2011
Posts: 925
|
The usb_open() call fails and you forgot to check return value of it. Then it tries to call usb_get_string_simple() with a NULL pointer udh that leads to a SIGSEGV.
|
|
1 members found this post helpful.
|
01-22-2014, 09:54 PM
|
#3
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442
Original Poster
Rep:
|
Quote:
Originally Posted by jtsn
The usb_open() call fails and you forgot to check return value of it. Then it tries to call usb_get_string_simple() with a NULL pointer udh that leads to a SIGSEGV.
|
Thanks. All boils down then to why it returns a null pointer.
Last edited by stf92; 01-22-2014 at 10:27 PM.
Reason: Grammatical error.
|
|
|
01-22-2014, 09:55 PM
|
#4
|
Senior Member
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860
|
Well, that's why someone wrote DDD.
|
|
|
01-22-2014, 10:20 PM
|
#5
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442
Original Poster
Rep:
|
But the program is already debugged and running properly on 12.0. So there should be an explanation not envolving the complexities of debugging and recoding. Or stating what precisely should be recoded.
|
|
|
01-23-2014, 04:48 AM
|
#6
|
Senior Member
Registered: Apr 2009
Location: McKinney, Texas
Distribution: Slackware64 15.0
Posts: 3,860
|
Quote:
Originally Posted by stf92
But the program is already debugged and running properly on 12.0. So there should be an explanation not envolving the complexities of debugging and recoding. Or stating what precisely should be recoded.
|
Well, you're the one with all the source code. Start reading. Since the kernel, glibc, libusb, and damn near everything else changed between 12.0 and 14.0, you've got a lot of reading and analysis to do. Let us know how that comes out.
|
|
1 members found this post helpful.
|
01-23-2014, 07:43 AM
|
#7
|
Senior Member
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 4,442
Original Poster
Rep:
|
I'll be better off working on the old machine. Being new to USB, I've already studied the driver, both the C part and the assembler part exhaustively, toghether with the essentials of USB 1.1 (with the specification in my hand) reaching a point where I have a pretty good understanding of USB (bare bones) and the program. All of this made analitically. No recourse to instruments. Have modified it to my taste and made it run. Though this knowledge is feeble, just acquired and needing the soundness that comes with practice. After all this work, don't feel like getting into the complexities of an O.S. Thanks for pointing out the large differences between 12.0 and 14.0, thus saving me work.
|
|
|
All times are GMT -5. The time now is 01:40 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|