From Bugzilla Helper: User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) Description of problem: I have created a small C++ exe using the RPM API rpmInstallSourcePackage(). However, when running the program it seg faults on rpmInstallSourcePackage(). It is seg. faulting on the function rpmInstallSourcePackage() in Fileno() from /usr/lib/librpmio. The debugger shows me that before it seg faults, the program will trace through the lib's rpmInstallSourcePackage(), queryArgCallback (), rpmInstallSourcePackage(), rpmreadPackageHeader(),readPackageHeaders() and finally choke on some Fileno(). my usage of the function is as follows ... rpmInstallSourcePackage(rootDir, fd, specFilePtr,0,0,0) where rootDir is a const char * = "to/some/path" where fd = Fopen(argv[1]) where specFilePtr is a const char **="to/some/path" and I substitute null for the rest. My program is very simple and only calls two functions from the API. The Fopen and rpmInstallSourcePackage(). Version-Release number of selected component (if applicable): How reproducible: Always Steps to Reproduce: 1.run the program e.g.- # ./instllpkg /development/RPMS/i386/somepkg.rpm 2. 3. Actual Results: Segmentation fault in the function call in Fileno() from /usr/lib/librpmio 4.0.3.so Expected Results: The program should execute without segmentation faults, install package as specified and write output that it has installed package. Additional info: I'm not sure that this is a bug of rpm. Given my lack of knowledge to the rpm API I could be giving it bad params or giving it null when it is expecting a param.
If your program is small, can you attach here? I can probably tell you what's up even though I'm not a C++ programmer.
Jeff, I made some progress with my bug. I ended up using rpmInstall() vs. rpmInstallSource(). However, I now get another seg fault that says Error: no db path set. The source is as follows. #include <rpm/rpmlib.h> void main() { const char * rootdir = "/development" char * str[]={"/development/RPMS/i386/IM-0.1-1.i386.rpm"}; str[1]='/0'; const char ** temp = const_cast<const char**>(str); rpmInstall(rootdir,temp,RPMTRANS_FLAG_NONE,INSTALL_HASH,RPMPR0B_FILTER_NONE,0); }
All programs that link against rpmlib need to do if (rpmReadConfigFiles(rcfile, NULL)) exit(EXIT_FAILURE); early on.
ok, something is weird with rpm and its files. My rpmrc file resides in /usr/lib. It's visible to ls and when I do rpm --showrc it shows the contents of that file. However, when I use the command # more /usr/lib/rpmrc, it says no such file or dir. This error also happens when I supply this file to rpmReadConfigFiles("/usr/lib/rpmrc", NULL). Another weird thing is that I went to view /usr/include/rpmlib.h with the more command and it says that that file dn exist, but it does! I must be doing something wrong????
There may be a /usr/lib/rpmrc symlink, but the file(s) you want/need are /usr/lib/rpm/rpmrc /usr/lib/rpm/macros and (possibly) /usr/lib/rpm/<arch>-linux/macros This is what is read by rpmReadConfigFiles(NULL, NULL); (Yes, NULL will use defaults).
If you need more help, please reopen this bug. Meanwhile I'm gonna close.