eConsoleAppContainer crash

Alles rund um das grafische Benutzerinterface Enigma
dAF2000
Neugieriger
Neugieriger
Beiträge: 3
Registriert: Freitag 10. Dezember 2004, 21:26

eConsoleAppContainer crash

Beitrag von dAF2000 »

I use the eConsoleAppContainer to execute scripts/programs. But it fails when I execute a script (which works fine from the shell, chmod and all done), while executing "normal" programs like "ls" do not fail.

This fails:

Code: Alles auswählen

cmd = new eConsoleAppContainer("/var/bin/script")
This works fine:

Code: Alles auswählen

cmd = new eConsoleAppContainer("ls /var")
Do I do something wrong or could this be a bug in Enigma?
The problem remains if I use eStrings instead of the quoted string.
digi_casi

Beitrag von digi_casi »

system("/var/bin/script");
should do as well...
dAF2000
Neugieriger
Neugieriger
Beiträge: 3
Registriert: Freitag 10. Dezember 2004, 21:26

Beitrag von dAF2000 »

digi_casi hat geschrieben:system("/var/bin/script");
should do as well...
That would be a solution, indeed.
I've noticed that eConsoleAppContainer crashes if no arguments are given to the command to be executed. Thus, "var/bin/script" crashes and "/var/bin/script 0" doesn't. Maybe, still a bug? Two other developers saw the same crash.
Sat-turner
Neugieriger
Neugieriger
Beiträge: 11
Registriert: Freitag 18. März 2005, 13:47

Beitrag von Sat-turner »

Hello,

There seems to be a bug in eConsoleAppContainer(). Below is a patch that will fix it (tabs may be converted to spaces). I tested it and it works fine.

Code: Alles auswählen

Index: apps/tuxbox/enigma/lib/base/console.cpp
===================================================================
--- apps/tuxbox/enigma/lib/base/console.cpp     (revision 1)
+++ apps/tuxbox/enigma/lib/base/console.cpp     (working copy)
@@ -180,6 +180,8 @@
                argv[cnt] = new char[ cmds.length() ];
                strcpy( argv[cnt], cmds.c_str() );
        }
+       else
+               cnt = 0 ;

   // get one read ,one write and the err pipe to the prog..

Cheers,
Sat-Turner
mirakels
Neugieriger
Neugieriger
Beiträge: 17
Registriert: Montag 8. November 2004, 23:48

Beitrag von mirakels »

Actually there is another problem in the code. After the cvs update of Sat-turners patch and an aditional optimization of ghostrider the code looks like:

Code: Alles auswählen

	}
	else
		cnt=0;

  // get one read ,one write and the err pipe to the prog..

//	int tmp=0;
//	while(argv[tmp])
//		eDebug("%d is %s", tmp, argv[tmp++]);
  
	pid = bidirpipe(fd, argv[0], argv);

	while ( cnt > 0 )  // release heap memory
		delete [] argv[cnt--];
	delete [] argv;
The 'cnt >0' means it will never release argv[0] which holds the actual command, so we get a memory leak.

To fix this I think the code should read like this:

Code: Alles auswählen

   }
	else
		cnt=1;

  // get one read ,one write and the err pipe to the prog..

//	int tmp=0;
//	while(argv[tmp])
//		eDebug("%d is %s", tmp, argv[tmp++]);
  
	pid = bidirpipe(fd, argv[0], argv);

	while ( cnt >= 0 )  // release heap memory
		delete [] argv[cnt--];
	delete [] argv;
e.g. sat-turners patch is changed to do a 'cnt=1', and the while clause is changed to check on cnt>=0.

I already discussed this with sat-turner and he agrees...