VLC plugin out of tree build results in segmentation fault - plugins

I'm trying to build an 'out of tree' plugin for VLC.
Computer Specs: Intel x64 Ubuntu 12.04
VLC Specs: VLC media player 2.0.8
To tackle this I
cloned the VLC git repository
added my module (just a copy of vmem with some name changes)
added modules info to the autotools
It worked! I can see my module in VLC when I go to tools->preferences->video->output.
I want to do the same thing 'Out of Tree' where I build the module independent of the VLC tree and copy the generated shared object library to a place where VLC can read it and VLC detects it.
I followed the instructions on here:
VLC Out of tree compile
I copied my 'in tree' module to a new directory
Wrote a SConstruct file to build it based off of the instructions from above as well as the instructions on http://wiki.videolan.org/Documentation:VLC_Modules_Loading/
Here is a shortened version of the module:
#define DOMAIN "vlc-nysa"
#define _(str) dgettext(DOMAIN, str)
#define N_(str) (str)
#define MODULE_STRING "nysa-video"
vlc_module_begin()
/* VLC Uses these to identify the module */
set_text_domain (DOMAIN)
set_description (N_("Nysa Video Output" ))
set_shortname (N_("Nysa Video" ))
set_category (CAT_VIDEO )
set_subcategory (SUBCAT_VIDEO_VOUT )
set_capability ("vout display", 1 )
/* Options left out for brevity */
/* Add Callbacks */
set_callbacks (Open, Close )
vlc_module_end()
/* implementation here */
Output
So people don't have to figure out the scons syntax here is the build output:
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
gcc -o src/nysa_video.os -c -std=gnu99 -Wall -Wextra -O2 -fPIC -fPIC -D__PLUGIN__ -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D_THREAD_SAFE -DPIC -I/usr/include/vlc -I/usr/include/vlc/plugins -Iinclude src/nysa_video.c
gcc -o build/libnysa_video_plugin.so -Wl,-no-undefined,-z,defs -shared src/nysa_video.os -L/usr/lib -L/usr/local/lib -lvlc -lvlccore
scons: `install' is up to date.
scons: done building targets.
Results
I do get a file called libnysa_video_plugin.so which I copy into /usr/lib/vlc/plugins/video_output directory
When I run VLC I get a seg fault:
VLC media player 2.0.8 Twoflower (revision 2.0.8a-0-g68cf50b)
Segmentation fault (core dumped)
dmesg | tail prints out:
[141376.468964] vlc[27609]: segfault at 88 ip 00007f06ccd6a4db sp 00007fff029a6310 error 6 in libvlccore.so.5.1.1[7f06ccce4000+db000]
Here is a link to my git repo for this project:
Nysa Video Git Repo
To build you need scons and in the base directory:
to build: scons
to install (installs to /usr/lib/vlc/plugins/video_output): sudo scons install

I found there was a bug in my code
vlc_module_begin()
/* VLC Uses these to identify the module */
set_text_domain (DOMAIN) //THIS SHOULDN'T BE HERE
set_description (N_("Nysa Video Output" ))
I felt bad for posting this question when it was simply a bug so I created a git repo that will hopefully help someone looking to build an out of tree plugin for VLC.
VLC Out of tree Plugin
There are instructions in the readme

Related

Using -fsanitizer on vscode

Using -fsanitizer while compiling programs helps in finding location of memory leaks easily. But how to use this with vscode.
I only know that for compiling a program in vscode through terminal we need to type in g++ file_name.cpp -o executable_name.exe and for running .\program_name
Adding -fsanitizer to this command as an argument does not work for me. How to compile your program using fsanitizer on vscode?
Edit: I have been trying to use it as
g++ -std=c++17 -O2 -Wall -fsanitize=address
tempCodeRunnerFile.cpp -o tempcodeRunnerfile.exe
But this keeps giving me some kind of error:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lasan: No such file or directory
collect2.exe: error: ld returned 1 exit status
This is unrelated to VSCode. The problem is your platform - MinGW traditionally has poor sanitizer support.
Your MSYS2 environment, MINGW64, only supports UBSAN (with stripped-down error reporting, compile with -fsanitize=undefined -fsanitize-undefined-trap-on-error).
There's also CLANG64 environment, which does have ASAN. Install its Clang (pacman -S mingw-w64-clang-x86_64-clang), and compile using clang++ located at C:\msys64\clang64\bin. If you're compiling from MSYS2 terminal, make sure you start the right one: launch it with clang64.exe, or the "MSYS2 Clang x64" shortcut (I don't remember the exact name).

Wireshark dissector errors Ubuntu

I have a wireshark plugin code which compiles and generates .so files perfectly under Ubuntu 16. This dissector was written for wireshark 1.6 and the plugin runs perfectly under wireshark 1.6.
However when I try to use this plugin for wireshark 2(or any wireshark version higher than 1.6) following errors show -
Couldn't load module
/home/th89ct/.config/wireshark/plugins/plugin-1_0_0.so:
/home/th89ct/.config/wireshark/plugins/plugin-1_0_0.so: undefined
symbol: tvb_length
Couldn't load module
/home/th89ct/.config/wireshark/plugins/plugin--1_0_0.so:
/home/th89ct/.config/wireshark/plugins/plugin--1_0_0.so: undefined
symbol: check_col
so I wanted to edit the code by replacing the methods - as after googling I've found that these methods do not belong to the new wireshark API.
but the problem is every time I edit the code - even by only putting a space in a blank space - following error appears -
*gcc -c -DHAVE_CONFIG_H -I/usr/include/wireshark -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -DINET6 -D_U_=attribute((unused)) -Wall -Wpointer-arith -g -DXTHREADS -D_REENTRANT -DXUSE_MTSAFE_API -fPIC -DPIC packet-ife.c -o packet-ife.o packet-ife.c:105:23: fatal error: epan/emem.h: No such
file or directory #include
^ compilation terminated. Makefile.linux:28: recipe for target 'packet-ife.o' failed make: *** [packet-ife.o] Error
1*
what should I do? I have no idea!!!! Thanks in advance
Your problem here is that emem was replaced with wmem starting with Wireshark 2.0. You can read more about wmem in Wireshark's README.wmem file. Naturally, there are plenty of dissectors available in Wireshark's epan/dissectors/ and plugins/*/ directories to serve as excellent examples to help you with the transition.

How do I develop bare-metal i.mx6sx code using eclipse?

I was wondering if you could help me with some issues and questions I have for developing for the i.MX6 SoloX in bare-metal. I was looking at this link https://community.nxp.com/docs/DOC-106253 and downloaded the files there to use as an example of how to develop bare-metal c code for the i.MX6.
Then I setup my eclipse environment according to this tutorial https://community.nxp.com/docs/DOC-103736 but just the toolchain because I'm not interested in processor expert.
Since I'm working on Linux I didn't installed the Code Sourcery thing, instead I'm working with the gcc-arm-none-eabi which I installed using:
$ sudo apt-get install gcc-arm-none-eabi
And therefore I had to change the cs-rm and cs-make for rm and make respectively.
And I was able to create an eclipse project with the downloaded code and configure the project to make it work, nevertheless, I had the first error:
main.c:8:19: fatal error: stdio.h: No such file or directory
#include <stdio.h>
^
compilation terminated.
make: *** [cortex_A9/main.o] Error 1
cortex_A9/subdir.mk:24: recipe for target 'cortex_A9/main.o' failed
And I was able to solve it adding "/usr/include" in the include directories at project > properties. But I'm not sure if this is a correct way of solving this error.
After fixing this error I got a new one:
syscalls.c:168:1: error: unknown type name 'caddr_t'
caddr_t _sbrk(int incr)
And for solving that I had to include explicitly the file "/usr/include/x86_64-linux-gnu/sys/types.h" and also I don't know if that is the correct way to solve it.
Now having eliminated those two errors I have the following one:
Building target: imx6-A9.elf
Invoking: Cross ARM C Linker
arm-none-eabi-gcc -mcpu=cortex-a9 -march=armv7-a -marm -mlittle-endian -mfloat-abi=softfp -mfpu=neon -mno-unaligned-access -fno-zero-initialized-in-bss -O0 -g -T "/home/mmalagon/iMX6/MX6SX_hello_MFG/cortex_A9/mx6slx.ld" -nostartfiles -Wl,-Map,"imx6-A9.map" -o "imx6-A9.elf" ./cortex_A9/main.o ./cortex_A9/syscalls.o ./cortex_A9/uart.o
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/bin/ld: cannot find -lg
makefile:42: recipe for target 'imx6-A9.elf' failed
/usr/lib/gcc/arm-none-eabi/4.9.3/../../../arm-none-eabi/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
make: *** [imx6-A9.elf] Error 1
Which I haven't been able to resolve.
I don't know if this error is a consequence of the way I solved the two previous errors.
Does anybody know how to properly setup eclipse for i.MX6 bare-metal development?
Thank you very much for helping!!
If you want to develop bare-metal code for the i.MX6SoloX without using CodeSourcery then you need to execute this:
sudo apt-get install gcc-arm-none-eabi libnewlib-arm-none-eabi -y
And then choose "Custom (arm-none-eabi-gcc)" at Project>Settings>C/C++ Build in the 'Toolchains' tab.

Beaglebone C/C++ programing in windows 7

I have a Beaglebone (Rev: A6) and i want to develop C/C++ program in windows 7 using Eclipse and then transfer executable in the board. But i'm having trouble setting up compiler/debugger/toolchain needed for Beaglebone. Searching the internet only gives me how to setup environment in Linux like installing 'arm-linux-gnueabi', setting up the paths to 'includes' etc. I need a step by step instruction to set up the environment in Eclipse in a windows machine. Can anyone help ?
I have tried these steps:
1. I have GNUARM installed on windows.
2. On eclipse IDE i open a C++ project with Corss GCC.
3. From project -> properties -> C/C++ build -> settings i add 'arm-elf-' to every cross compiler command.
4. From the GNUARM installation directory i add few path to '.../include/' in the 'C++ General -> paths and symbos'.
my 'build all' shows something as below:
10:32:20 **** Build of configuration Debug for project h ****
make all
Building file: ../src/hello.cpp
Invoking: Cross G++ Compiler
arm-elf-g++ -I"C:\GNUARM\include\c++\4.1.1" -I"C:\GNUARM\include\c++\4.1.1\arm-elf" - I"C:\GNUARM\include\c++\4.1.1\backward" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP - MF"src/hello.d" -MT"src/hello.d" -o "src/hello.o" "../src/hello.cpp"
Finished building: ../src/hello.cpp
Building target: h
Invoking: Cross G++ Linker
arm-elf-g++ -L"C:\GNUARM\lib\gcc\arm-elf\4.1.1\include" -o "h" ./src/hello.o
Finished building target: h
10:32:23 Build Finished (took 2s.967ms)
It is simple 'Hello world' printing program. From the project explorer 'Debug->src->hello.o -[arm/le]' i copy it and when run on beaglebone with
chmod ugo+x hello.o
./hello.o
-sh: ./hello.o: cannot execute binary file
the above massage is printed. I don't know what i did wrong. Perhaps the ARM environment in eclipse is set up incorrectly.
Isn't hello.o the pre-linked object file (just the compiled content of hello.cpp)? It doesn't contain the startup code or any library functions. The linker adds those to produce the final output.
Don't you want to run the linker ouput file h (which should already be executable)?
i got my answer here. http://www.acmesystems.it/foxg20_eclipse_windows_c. CodeSourcery was the toolchain that i was looking for and this also explains how to setup the corss compiling environment.

Trouble Installing Arduino on Netbeans in Ubuntu 11

I am a complete noob to Arduino trying to make my first program. I have Netbeans installed and I wanted to do my first Arduino program using Netbeans. I found the following site that has some step-by-steps. http://java.dzone.com/news/arduino-development-using
I am using NetBeans 7 on a Fresh install of Ubuntu 11. I have been going step-by-step through the site.
My first hint that there is a problem is that the code Assist isn't working at all.
My next problem is that when I compile the default main.pde I get the following error:
fatal error: WProgram.h: No such file or directory in
cat main.pde >> applet/ArduinoTest1.cpp
/usr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -DF_CPU=16000000L -DARDUINO=18 -I/home/tmonteit/arduino-0018/hardware/arduino/cores/arduino -I/home/tmonteit/arduino-0018/libraries -mmcu=atmega328p applet/ArduinoTest1.cpp -o applet/ArduinoTest1.o
applet/ArduinoTest1.cpp:1:22: fatal error: WProgram.h: No such file or directory
compilation terminated.
make: *** [applet/ArduinoTest1.o] Error 1
When I troubleshoot similar problems online it seems that you have to make sure that you are using the correct library.
To install I used apt-get install librxtx-java arduino-core arduino
And then I downloaded arduino-1.0
How do I know if I have the correct libraries or setup?
Is there a proper way to get the right version of these libraries and arduino that will work with NetBeans?
Is there an easy fix?
Since the version used in the guide you are using (Arduino 0018) there have been several library changes (mostly in Arduino 1.0 and notably the renaming of WProgram.h to Arduino.h).
To accommodate these changes the main.pde file will need to change to:
#define __AVR_ATmega328P__
#include <binary.h>
#include <HardwareSerial.h>
#include <pins_arduino.h>
#include <Arduino.h>
#include <wiring_private.h>
#include <EEPROM/EEPROM.h>
void setup()
{
}
void loop()
{
}
Also, pins_arduino.h has moved from hardware/arduino/cores/arduino to hardware/arduino/variants/standard so you'll need to add this to your include path.