Infinite child processes in cefsimple when CefMainArgs(0,0)

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Infinite child processes in cefsimple when CefMainArgs(0,0)

Postby dmklementiev » Fri Aug 23, 2019 4:32 pm

I am trying to run cefsimple with CefMainArgs main_args(0, nullptr) instead of CefMainArgs main_args(argc, argv) . When I do this the following line

pid = fork();

in function Process LaunchProcess(const std::vector<std::string>& argv, const LaunchOptions& options) - file src/base/process/launch_posix.cc) - generates infinite number of child processes which kills the machine by consuming all the memory. With CefMainArgs main_args(argc, argv) everything works fine.

Questions: am I doing something wrong? how this should be done correctly if so?

Thank you.
dmklementiev
Mentor
 
Posts: 54
Joined: Wed Jul 31, 2019 7:11 pm

Re: Infinite child processes in cefsimple when CefMainArgs(

Postby HarmlessDave » Fri Aug 23, 2019 5:56 pm

Are you throwing away the command-line arguments needed by the helper processes (renderer, etc.)? I haven't worked with linux or OS X so that's just guessing.
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: Infinite child processes in cefsimple when CefMainArgs(

Postby dmklementiev » Fri Aug 23, 2019 6:34 pm

Thank you for the reply. Assuming that I my understanding of what "throwing away" means - yes I am completely ignoring argv in main. To add to it: std::vector<char*> argv_cstr in function Process LaunchProcess has the following values:

/home/dmitri/MSAL/CEF/cefsample/bin/cefsimple
--type=zygote
--no-sandbox
--log-file=/home/dmitri/MSAL/CEF/cefsample/bin/debug.log
--lang=en-US

And this is the process that just creates child process recursively with the same parameters. I checked the tree in htop. Am I correct that this is happening because all those params are ignored in child process(es) and if yes, what would be the best way to address it?

My original problem is that I want to create dll (.so) that provides cef functionality and I won't know how it will be called, so I am trying to run cefsimple with int main() - just to try how it is going to work). When I try to use char *argvLocal[] to initilize CefMainArgs(1,argvLocal), then void setproctitle(const char* fmt, ...) (in /services/service_manager/embedder/set_process_title_linux.cc) throws SIGSEGV at line memset(g_main_argv[0], 0, avail_size). My guess this is hapenning because value of avail_size is too big.
dmklementiev
Mentor
 
Posts: 54
Joined: Wed Jul 31, 2019 7:11 pm

Re: Infinite child processes in cefsimple when CefMainArgs(

Postby HarmlessDave » Fri Aug 23, 2019 7:15 pm

In Windows, a command line is sent to each child / helper processes that tells them things including what kind of helper process it is (renderer, plugin, ...).

So if there is no command line the child process will think that it is the (first / main / browser / UI) process and it will run the main process initialization code including attempting to create its own helper processes. If they also are also missing their command line, the real first process spawns +2, who spawn +4, +8, +16, ...

https://bitbucket.org/chromiumembedded/ ... -processes
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: Infinite child processes in cefsimple when CefMainArgs(

Postby dmklementiev » Fri Aug 23, 2019 7:34 pm

Yes, this makes sense. With this information I will investigate how I can solve my original problem, thank you and have a great weekend : )
dmklementiev
Mentor
 
Posts: 54
Joined: Wed Jul 31, 2019 7:11 pm

Re: Infinite child processes in cefsimple when CefMainArgs(

Postby dmklementiev » Wed Aug 28, 2019 8:01 pm

I've got this kind of working (thank you for your help) by calculating the address of argv[0] sent to the main executable and number of arguments (argc) and using them as arguments for CefMainArgs(). This doesn't work very well if I want to use CEF support in a dll, because, if I understand it correctly, CEF will start the main application which is not small. So I ended up with just creating a separate process - pretty much cefsimple. This is a bit inconvenient, so question:

Does cefclient addresses the problem I am encountering and if yes - are there any plans to enable a build of it for arm64. Asking since Marshall mentioned in this thread https://magpcss.org/ceforum/viewtopic.php?f=6&t=16963 that
The sysroot doesn’t contain the deps required by cefclient. Build the cefsimple target instead.
dmklementiev
Mentor
 
Posts: 54
Joined: Wed Jul 31, 2019 7:11 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 55 guests