[Beowulf] Seg Fault with pvm_upkstr() and Linux.

Josh Zamor jzamor at gmail.com
Wed Mar 16 12:14:52 PST 2005

On Mar 16, 2005, at 7:30 AM, Robert G. Brown wrote:

> I assume that you've experimented and have no difficulty returning and
> unpacking ordinary ints, strings, or raw data blocks with PVM.  If so
> you probably aren't making a pointer error on the master server side,
> although it never hurts to check.

Actually, I had tried passing ints and the like in other programs and 
had no problem, but when I tired to pass just a string in my factorial 
program, not using GMP, but still having the GMP library, it would 
segfault. What I hadn't tried was to create a simple test program for 
just sending strings using PVM. I have now written a test program that 
does not use the GMP and tries to send a basic string back from a child 
to the parent. This again will segfault on the linux machine and work 
just fine on the OSX machine (essentially BSD). The code that I tried 
is posted below. For convenience I have also posted the source of this 
test program, my simple factorial program, Makefiles, and script 
outputs from both OSX and the linux machine at the following address:   


#include <pvm3.h>
#include <stdio.h>

int main(int argc, char** argv) {
     int info, mytid, myparent, child[2];

     if(mytid = pvm_mytid() < 0) {
	pvm_perror("Could not get mytid");
	return -1;

     myparent = pvm_parent();
     if((myparent < 0) && (myparent != PvmNoParent)) {
	pvm_perror("Some odd errr for my parent");
	return -1;

     /* I am parent */
     if(myparent == PvmNoParent) {
	info = pvm_spawn(argv[0], NULL, PvmTaskDefault, NULL, 2, child);

	for(int i = 0; i < 2; ++i) {
	    if(child[i] < 0)
		printf(" %d", child[i]);
		printf("t%x\t", child[i]);

	if(info != 2) {
	    pvm_perror("Kids didn't all spawn!");
	    return -1;

	for(int i = 0; i < 2; ++i) {
	    char* retStr;
	    info = pvm_recv(-1, 11);
	    info = pvm_upkstr(retStr);
	    printf("Recieved return string: %s\n", retStr);

	return 0;
     } else { /* Child follows */
	char str[3];
	str[0] = 'a';
	str[1] = 'b';
	str[3] = (char)0;
	pvm_send(myparent, 11);
	return 0;

Also, for the character array "str" in the child segment above, I have 
tried using malloc to create the memory, and using const char arrays as 
well. While all of these methods give seg faults on the linux machine, 
the above way was the only way that I tried that worked and didn't give 
a bus error on Mac OSX.

Thanks again.

More information about the Beowulf mailing list