简体   繁体   English

以用户身份而不是sudo运行libusb 1.0程序中的分段错误

[英]Segmentation fault in libusb 1.0 program when run as user, not as sudo

I'm writing a camera capture program that uses libusb 1.0 and cImg. 我正在编写一个使用libusb 1.0和cImg的相机捕获程序。 It connects to my Atik 314L astronomy camera and captures images to display on screen. 它连接到我的Atik 314L天文相机,并捕获图像以显示在屏幕上。 It compiles fine when compiled as regular or superuser and runs well when executed as a root user, but generates a segmentation fault when run any other way. 当以常规或超级用户身份编译时,它可以很好地编译,以根用户身份运行时,它可以很好地运行,但是以任何其他方式运行时,都会产生分段错误

I'm using Code::Blocks , and the call stack shows that the segmentation fault happens when calling the usb_control_msg() function: 我正在使用Code :: Blocks ,并且调用堆栈显示在调用usb_control_msg()函数时发生分段错误:

#0 (usb_control_msg(dev=0x0, requesttype=64, request=160, value=58880, index=0 bytes=0x7fffffffe5df "\001 \346\377\377\377\177", size=1, timeout=500) (linux.c:152)

I'm rather new to programming in a Linux environment, and I'm not sure what to do to get this to run for normal users. 我对Linux环境中的编程很陌生,而且我不确定该如何为普通用户运行它。 Here are the steps I've tried so far: 到目前为止,这是我尝试过的步骤:

  1. Add my user to all user groups to see if it's a group permissions issue (heck-- I even tried adding myself to "root", but it didn't do anything) 将我的用户添加到所有用户组中,以查看是否存在组权限问题(哎呀,我什至尝试将自己添加到“ root”,但它什么也没做)
  2. Add a rule to /etc/udev/rules.d that went a little something like this: PROGRAM="/home/[username]/git/camera/prog", MODE="0660", GROUP="camera" 将规则添加到/etc/udev/rules.d ,如下所示:PROGRAM =“ / home / [用户名] / git / camera / prog”,MODE =“ 0660”,GROUP =“ camera”
  3. Try to change permissions of the program itself to 777. That was a last ditch effort though-- I didn't really expect it to work. 尝试将程序本身的权限更改为777。尽管这是最后的努力-我并不是真的希望它能起作用。

I'm learning how to debug as I go, so if you need logs or anything to see what's wrong, just let me know. 我正在学习如何进行调试,因此,如果您需要日志或其他任何东西以查看有什么问题,请告诉我。

You possibly need to set/get the flags of the device using a function like fnctl() , and according to your requirement you can set the file access mode ( O_RDONLY / O_WRONLY / O_RDWR ) and file creation flags ( O_CREAT / O_EXCL / O_NOCTTY / O_TRUNC ). 您可能需要使用诸如fnctl()类的功能来设置/获取设备的标志,并且根据您的要求,您可以设置文件访问模式( O_RDONLY / O_WRONLY / O_RDWR )和文件创建标志( O_CREAT / O_EXCL / O_NOCTTY / O_TRUNC )。 However, on Linux this command can change only the O_APPEND, O_ASYNC, O_DIRECT, O_NOATIME and O_NONBLOCK flags. 但是,在Linux上,此命令只能更改O_APPEND, O_ASYNC, O_DIRECT, O_NOATIMEO_NONBLOCK标志。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我尝试运行程序时出现分段错误错误 - Segmentation Fault Error when I try to run program 以root身份运行时出现分段错误? - Segmentation fault when run as root? 当我运行我的程序时,我将此作为运行时错误分段错误(SIGSEGV) - When i run my program I get this as a run time error Segmentation Fault (SIGSEGV) 使用push时队列程序中的分段错误 - Segmentation fault in queue program when using push 程序退出时在__tcf_0处出现分段错误 - segmentation fault at __tcf_0 when program exits C ++:运行程序时出现分段错误(从文件中输入数字到数组) - C++: Getting a Segmentation Fault when I run my Program (inputting numbers from a file into arrays) 尝试运行Queue程序时出现分段错误(核心已转储)-C ++ - Segmentation Fault (core dumped) when trying to run Queue program - C++ 为什么在运行程序时出现错误“细分错误”? - Why am i getting the error “segmentation fault” when i run the program? 当程序根据用户输入再次循环时,它会导致分段错误:11 - When program is expected to loop through again based on user input, it instead results in Segmentation Fault: 11 在makefile中运行应用程序时出现分段错误 - Segmentation fault when run an application out of makefile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM