Erlang error exception exit in ZeroMQ example - erlang

i run hwclient:main(). or hwserver:main().
from zeromq example for erlang
https://github.com/zeromq/ezmq/blob/master/examples
from link
http://zeromq.org/bindings:erlang
and have error "exception exit"
crasher:
initial call: ezmq:init/1 pid: <0.42.0> registered_name: []
exception exit: {noproc,
{gen_server,call,
[ezmq_link_sup,{start_child,[]},infinity]}}
in function gen_server:terminate/6 (gen_server.erl, line 746)
ancestors: [<0.31.0>] messages: [] links: [] dictionary: [] trap_exit: true status: running heap_size: 376 stack_size: 27 reductions: 174
neighbours:
** exception exit: {{noproc,
{gen_server,call,
[ezmq_link_sup,{start_child,[]},infinity]}},
{gen_server,call,
[<0.42.0>,{connect,tcp,{127,0,0,1},5555,[]}]}}
in function gen_server:call/2 (gen_server.erl, line 182)
in call from hwclient:main/0 (/examples/hwclient.erl, line 15)
what's wrong?

Related

Issue when trying to run Webdriver IO (end to end) tests in a Gitlab CI pipeline runner using a docker image

This is my first time posting in this plateform so if my request lacks informations let me know so I can provide them.
I'm trying to run my end to end tests using Webdriver IO, I've been running my tests locally at first but now I need to execute them in a Gitlab CI pipeline using a docker image, and here are some information about the setup:
Docker image:
it's an alpinedocker image
node version: 12.18.3
npm version:6.14.6
Java version: openjdk "11.0.8"
Chromium: 85.0.4183.83
Mozilla: 80.0.1
Webdriver IO configuration:
latest versions of webdriver IO framework, geckodriver, and wdio-geckodriver-service
Here is my wdio.cong.js file
const { generate } = require('multiple-cucumber-html-reporter');
const { removeSync } = require('fs-extra');
exports.config = {
runner: 'local',
maxInstances: 1,
capabilities: [
{
maxInstances: 1,
browserName: 'firefox',
acceptInsecureCerts: true,
'moz:firefoxOptions': {
args: ['--headless', '--lang=fr-FR', '--disable-dev-shm-usage']
}
}
],
specs: ['./features/adminNavigation.feature'],
logLevel: 'info',
bail: 0,
baseUrl: 'http://localhost:3000',
waitforTimeout: 10000000,
connectionRetryTimeout: 120000,
connectionRetryCount: 3,
services: ['geckodriver'],
framework: 'cucumber',
reporters: [
[
'cucumberjs-json',
{
jsonFolder: './cucumberjs-reports/json',
language: 'en'
}
]
],
cucumberOpts: {
timeout: 40000,
requireModule: [
'tsconfig-paths/register',
() => {
require('ts-node').register({ files: true, project: './tsconfig.json' });
}
],
require: ['./**/**/*.step.ts']
},
onPrepare: function(config, capabilities) {
removeSync('./cucumberjs-reports');
},
onComplete: function(exitCode, config, capabilities, results) {
generate({
jsonDir: './cucumberjs-reports/json',
reportPath: './cucumberjs-reports/report'
});
}
};
My package.json:
"geckodriver": "^1.20.0",
"#wdio/cli": "^6.4.5",
"#wdio/cucumber-framework": "^6.4.3",
"#wdio/local-runner": "^6.4.5",
"#wdio/mocha-framework": "^6.4.0",
"#wdio/selenium-standalone-service": "^6.4.7",
"#wdio/spec-reporter": "^6.4.0",
"#wdio/sync": "^6.4.5",
"chromedriver": "^85.0.1",
"wdio-chromedriver-service": "^6.0.4",
"wdio-cucumberjs-json-reporter": "^2.0.2",
"wdio-geckodriver-service": "^1.1.0",
And here's the error logs :
Execution of 1 spec files started at 2020-09-11T13:15:06.515Z
2062020-09-11T13:15:06.519Z DEBUG #wdio/utils:initialiseServices: initialise service "geckodriver" as NPM package
2072020-09-11T13:15:06.522Z INFO #wdio/cli:launcher: Run onPrepare hook
2082020-09-11T13:15:06.525Z INFO #wdio/cli:launcher: Run onWorkerStart hook
2092020-09-11T13:15:06.535Z INFO #wdio/local-runner: Start worker 0-0 with arg: ./apps/front-e2e-wdio/wdio.ci.conf.js
210[0-0] 2020-09-11T13:15:07.117Z INFO #wdio/local-runner: Run worker command: run
211[0-0] 2020-09-11T13:15:07.247Z DEBUG #wdio/local-runner:utils: init remote session
212[0-0] 2020-09-11T13:15:07.252Z INFO webdriverio: Initiate new session using the ./protocol-stub protocol
213[0-0] RUNNING in firefox - /apps/front-e2e-wdio/features/adminNavigation.feature
214[0-0] 2020-09-11T13:15:07.749Z DEBUG #wdio/utils:initialiseServices: initialise service "geckodriver" as NPM package
215[0-0] 2020-09-11T13:15:07.772Z DEBUG #wdio/local-runner:utils: init remote session
216[0-0] 2020-09-11T13:15:07.774Z INFO webdriverio: Initiate new session using the webdriver protocol
217[0-0] 2020-09-11T13:15:07.778Z INFO webdriver: [POST] http://localhost:34305/session
218[0-0] 2020-09-11T13:15:07.778Z INFO webdriver: DATA {
219 capabilities: {
220 alwaysMatch: {
221 browserName: 'firefox',
222 acceptInsecureCerts: true,
223 'moz:firefoxOptions': [Object]
224 },
225 firstMatch: [ {} ]
226 },
227 desiredCapabilities: {
228 browserName: 'firefox',
229 acceptInsecureCerts: true,
230 'moz:firefoxOptions': { args: [Array] }
231 }
232}
233[0-0] 2020-09-11T13:15:10.623Z DEBUG webdriver: request failed due to response error: unknown error
234[0-0] 2020-09-11T13:15:10.624Z INFO webdriver: Retrying 1/3
2352020-09-11T13:15:10.624Z INFO webdriver: [POST] http://localhost:34305/session
2362020-09-11T13:15:10.624Z INFO webdriver: DATA {
237 capabilities: {
238 alwaysMatch: {
239 browserName: 'firefox',
240 acceptInsecureCerts: true,
241 'moz:firefoxOptions': [Object]
242 },
243 firstMatch: [ {} ]
244 },
245 desiredCapabilities: {
246 browserName: 'firefox',
247 acceptInsecureCerts: true,
248 'moz:firefoxOptions': { args: [Array] }
249 }
250}
251[0-0] 2020-09-11T13:15:10.623Z WARN webdriver: Request failed with status 500 due to invalid argument: can't kill an exited process
252[0-0] 2020-09-11T13:15:13.141Z DEBUG webdriver: request failed due to response error: unknown error
253[0-0] 2020-09-11T13:15:13.142Z WARN webdriver: Request failed with status 500 due to invalid argument: can't kill an exited process
254[0-0] 2020-09-11T13:15:13.142Z INFO webdriver: Retrying 2/3
255[0-0] 2020-09-11T13:15:13.143Z INFO webdriver: [POST] http://localhost:34305/session
256[0-0] 2020-09-11T13:15:13.143Z INFO webdriver: DATA {
257 capabilities: {
258 alwaysMatch: {
259 browserName: 'firefox',
260 acceptInsecureCerts: true,
261 'moz:firefoxOptions': [Object]
262 },
263 firstMatch: [ {} ]
264 },
265 desiredCapabilities: {
266 browserName: 'firefox',
267 acceptInsecureCerts: true,
268 'moz:firefoxOptions': { args: [Array] }
269 }
270}
271[0-0] 2020-09-11T13:15:15.558Z DEBUG webdriver: request failed due to response error: unknown error
272[0-0] 2020-09-11T13:15:15.567Z INFO webdriver: Retrying 3/3
273[0-0] 2020-09-11T13:15:15.567Z INFO webdriver: [POST] http://localhost:34305/session
274[0-0] 2020-09-11T13:15:15.568Z INFO webdriver: DATA {
275 capabilities: {
276 alwaysMatch: {
277 browserName: 'firefox',
278 acceptInsecureCerts: true,
279 'moz:firefoxOptions': [Object]
280 },
281 firstMatch: [ {} ]
282 },
283 desiredCapabilities: {
284 browserName: 'firefox',
285 acceptInsecureCerts: true,
286 'moz:firefoxOptions': { args: [Array] }
287 }
288}
289[0-0] 2020-09-11T13:15:15.566Z WARN webdriver: Request failed with status 500 due to invalid argument: can't kill an exited process
290[0-0] 2020-09-11T13:15:17.985Z DEBUG webdriver: request failed due to response error: unknown error
291[0-0] 2020-09-11T13:15:17.986Z ERROR webdriver: Request failed with status 500 due to unknown error: invalid argument: can't kill an exited process
2922020-09-11T13:15:17.986Z ERROR webdriver: unknown error: invalid argument: can't kill an exited process
293 at getErrorFromResponseBody (/builds/node_modules/webdriver/build/utils.js:121:10)
294 at WebDriverRequest._request (/builds/node_modules/webdriver/build/request.js:149:56)
295 at processTicksAndRejections (internal/process/task_queues.js:97:5)
296 at async startWebDriverSession (/builds/node_modules/webdriver/build/utils.js:41:16)
297 at async Function.newSession (/builds/node_modules/webdriver/build/index.js:44:23)
298 at async remote (/builds/node_modules/webdriverio/build/index.js:75:20)
299 at async Runner._startSession (/builds/node_modules/#wdio/runner/build/index.js:206:50)
300 at async Runner._initSession (/builds/node_modules/#wdio/runner/build/index.js:175:21)
301 at async Runner.run (/builds/node_modules/#wdio/runner/build/index.js:93:15)
3022020-09-11T13:15:17.987Z ERROR #wdio/runner: Error: Failed to create session.
303invalid argument: can't kill an exited process
304 at startWebDriverSession (/builds/node_modules/webdriver/build/utils.js:45:11)
305 at processTicksAndRejections (internal/process/task_queues.js:97:5)
306[0-0] Error: Failed to create session.
307invalid argument: can't kill an exited process
3082020-09-11T13:15:18.108Z DEBUG #wdio/local-runner: Runner 0-0 finished with exit code 1
309[0-0] FAILED in firefox - /apps/front-e2e-wdio/features/adminNavigation.feature
3102020-09-11T13:15:18.110Z INFO #wdio/cli:launcher: Run onComplete hook
3112020-09-11T13:15:18.112Z ERROR #wdio/cli:utils: Error in onCompleteHook: Error: There were issues reading JSON-files from './apps/front-e2e-wdio/cucumberjs-reports/json'.
312 at collectJSONS (/builds/node_modules/multiple-cucumber-html-reporter/lib/collect-jsons.js:16:15)
313 at generateReport (/builds/node_modules/multiple-cucumber-html-reporter/lib/generate-report.js:69:22)
314 at Object.onComplete (/builds/apps/front-e2e-wdio/wdio.ci.conf.js:44:5)
315 at /builds/node_modules/#wdio/cli/build/utils.js:109:13
316 at Array.map (<anonymous>)
317 at runOnCompleteHook (/builds/node_modules/#wdio/cli/build/utils.js:107:37)
318 at Launcher.run (/builds/node_modules/#wdio/cli/build/launcher.js:83:69)
319 at processTicksAndRejections (internal/process/task_queues.js:97:5)
320Spec Files: 0 passed, 1 failed, 1 total (100% completed) in 00:00:11
3212020-09-11T13:15:18.114Z INFO #wdio/local-runner: Shutting down spawned worker
3222020-09-11T13:15:18.365Z INFO #wdio/local-runner: Waiting for 0 to shut down gracefully
3232020-09-11T13:15:18.366Z INFO #wdio/local-runner: shutting down
edit
The commande that i'm using to run my tests is the following : "npx wdio wdio.conf.js".
And here's the Docker config file im using:
FROM alpine:latest
ARG BUILD_DATE
ARG VCS_REF
USER root
# Install node
RUN apk add --update nodejs npm
# Installs latest Chromium package.
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/main" > /etc/apk/repositories \
    && echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \
    && echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories \
    && echo "http://dl-cdn.alpinelinux.org/alpine/v3.11/main" >> /etc/apk/repositories \
    && apk upgrade -U -a \
    && apk add --no-cache \
    libstdc++ \
    chromium \
    harfbuzz \
    nss \
    freetype \
    ttf-freefont \
    wqy-zenhei \
    && rm -rf /var/cache/* \
    && mkdir /var/cache/apk
# Add Chrome as a user
RUN mkdir -p /usr/src/app \
    && adduser -D chrome \
    && chown -R chrome:chrome /usr/src/app
# Run Chrome as non-privileged
USER chrome
WORKDIR /usr/src/app
ENV CHROME_BIN=/usr/bin/chromium-browser \
    CHROME_PATH=/usr/lib/chromium/
USER root
# Install firefox
RUN apk upgrade --update-cache --available
RUN apk add xvfb firefox dbus py-pip ttf-dejavu
ENV FIREFOX_BIN=/usr/bin/firefox
# Install bash && curl
RUN apk add --no-cache bash
RUN apk --no-cache add curl
#ADD wait module
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.2.1/wait /wait
RUN chmod +x /wait
# Install Mongo Tools
RUN echo 'http://dl-cdn.alpinelinux.org/alpine/v3.9/community' >> /etc/apk/repositories
RUN apk add mongodb-tools
# Install jdk11
RUN apk --no-cache add openjdk11 --repository=http://dl-cdn.alpinelinux.org/alpine/edge/community
# Install chromeDriver
RUN apk add --no-cache chromium-chromedriver
RUN ls
RUN node -v
RUN npm -v
RUN java -version
RUN chromium-browser --version
RUN firefox --version
# RUN apt-cache policy chromium | grep Installed | sed -e "s/Installed/Chrome/"
CMD tail -f /dev/null 
please see a repo https://gitlab.com/bar_foo/wdio-cucumber-typescript for en example of how to run tests in Chrome and Firefox in the GitLab pipeline.
Note: you don't need Java in the image if you decided to use devtools automation protocol instead of webdriver protocol, see https://webdriver.io/blog/2019/09/16/devtools.html

Why does my supervisor fail on init with badarg?

I am trying to start a supervisor of type one_for_one with one child and am getting this error:
A = pl:start().
{error,{badarg,[{erlang,apply,[{state,[0|1]},init,[[]]],[]},
{supervisor,init,1,[{file,"supervisor.erl"},{line,295}]},
{gen_server,init_it,2,[{file,"gen_server.erl"},{line,374}]},
{gen_server,init_it,6,[{file,"gen_server.erl"},{line,342}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,249}]}]}}
=CRASH REPORT==== 1-Mar-2020::15:28:41.090000 ===
crasher:
pid: <0.215.0>
registered_name: []
exception error: bad argument
in function apply/3
called as apply({state,[0|1]},init,[[]])
in call from supervisor:init/1 (supervisor.erl, line 295)
in call from gen_server:init_it/2 (gen_server.erl, line 374)
in call from gen_server:init_it/6 (gen_server.erl, line 342)
ancestors: [<0.209.0>]
message_queue_len: 0
messages: []
links: [<0.209.0>]
dictionary: []
trap_exit: true
status: running
heap_size: 376
stack_size: 25
reductions: 192
neighbours:
neighbour:
pid: <0.209.0>
registered_name: []
initial_call: {erlang,apply,2}
current_function: {io,execute_request,2}
ancestors: []
message_queue_len: 0
links: [<0.63.0>,<0.215.0>]
trap_exit: false
status: waiting
heap_size: 1598
stack_size: 25
reductions: 5867
current_stacktrace: [{io,execute_request,2,[{file,"io.erl"},{line,579}]},
{shell,exprs,7,[{file,"shell.erl"},{line,693}]},
{shell,eval_exprs,7,[{file,"shell.erl"},{line,642}]},
{shell,eval_loop,3,[{file,"shell.erl"},{line,627}]}]
** exception exit: badarg
in function apply/3
called as apply({state,[0|1]},init,[[]])
in call from supervisor:init/1 (supervisor.erl, line 295)
in call from gen_server:init_it/2 (gen_server.erl, line 374)
in call from gen_server:init_it/6 (gen_server.erl, line 342)
in call from proc_lib:init_p_do_apply/3 (proc_lib.erl, line 249)
Supervisor:
-module(pl).
-behaviour(supervisor).
-export([start/0,init/1]).
-record(state,{
data=[]
}).
%% {ChildId, StartFunc, Restart, Shutdown, Type, Modules}
start()->
supervisor:start_link({local,?MODULE},#state{data=[0|1]},[]).
init(State=#state{data=D})->
InitialChild={fchild,{serv,start_link,[-1]},temporary,3000,brutal_kill,worker},
MaxRestart=2,
MaxTime=600,
Strategy={one_for_one,MaxRestart,MaxTime},
{ok,{Strategy,[
InitialChild
]}}.
Worker:
-module(serv).
-behaviour(gen_server).
-compile(export_all).
-define(A,300).
-record(state,{
values=[],
id
}).
call(Pid,Message)->
gen_server:call(Pid,Message).
cast(Pid,Message)->
gen_server:cast(Pid,Message).
start_link(Id)->
{ok,Pid}=gen_server:start_link({local,xx},?MODULE,[Id],[]),
Pid.
stop(Ref)->
gen_server:stop(Ref).
init(Id)->
{ok,#state{values=[],id=Id}}.
handle_call(state,From,State=#state{values=V})->
Reply={reply,State,State},
Reply;
I am just trying to start a supervisor with only one child that gets a parameter in its init method. What is wrong in this code?
The second argument of start_link with 3 arguments is supposed to be the module name; it should be
start()->
supervisor:start_link({local,?MODULE}, ?MODULE, [#state{data=[0|1]}]).

Why I get error: on_load_function_failed,re2

When I try to start the deployed app, I get this error:
initial_call: {supervisor,kernel,['Argument__1']}
pid: <0.1762.0>
registered_name: []
error_info: {exit,{on_load_function_failed,re2},[{gen_server,init_it,6,[{file,"gen_server.erl"},{line,352}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}
ancestors: [kernel_sup,<0.1738.0>]
messages: []
links: [<0.1739.0>]
dictionary: []
trap_exit: true
status: running
heap_size: 376
stack_size: 27
reductions: 117
2017-06-19 11:51:18 supervisor_report
supervisor: {local,kernel_sup}
errorContext: start_error
reason: {on_load_function_failed,re2}
offender: [{pid,undefined},{id,kernel_safe_sup},{mfargs,{supervisor,start_link,[{local,kernel_safe_sup},kernel,safe]}},{restart_type,permanent},{shutdown,infinity},{child_type,supervisor}]
2017-06-19 11:51:19 crash_report
initial_call: {application_master,init,['Argument__1','Argument__2','Argument__3','Argument__4']}
pid: <0.1737.0>
registered_name: []
error_info: {exit,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,re2}}},{kernel,start,[normal,[]]}},[{application_master,init,4,[{file,"application_master.erl"},{line,134}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}
ancestors: [<0.1736.0>]
messages: [{'EXIT',<0.1738.0>,normal}]
links: [<0.1736.0>,<0.1735.0>]
dictionary: []
trap_exit: true
status: running
heap_size: 376
stack_size: 27
reductions: 152
2017-06-19 11:51:19 std_info
application: kernel
exited: {{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,re2}}},{kernel,start,[normal,[]]}}
type: permanent
{"Kernel pid terminated",application_controller,"{application_start_failure,kernel,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,re2}}},{kernel,start,[normal,[]]}}}"}
Kernel pid terminated (application_controller) ({application_start_failure,kernel,{{shutdown,{failed_to_start_child,kernel_safe_sup,{on_load_function_failed,re2}}},{kernel,start,[normal,[]]}}})
But I have no idea how to solve this error.. any idea?
Phoenix app start:
def start(_type, _args) do
import Supervisor.Spec, warn: false
children = [
# Start the endpoint when the application starts
supervisor(MyApp.Endpoint, []),
# Start the endpoint for schools
supervisor(MyApp.Schools.Endpoint, []),
# Start the Ecto repository
supervisor(MyApp.Schools.Repo, []),
supervisor(MyApp.Repo, []),
]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end

getting {badarith,[{erlang,'+',[error,0],[]}, while performing arithmetic operation in TSUNG using Erlang snippet

I have wriiten a arithmetic snippet using TSUNG-Erlang function but unable to get through it successfully ; getting following error in my TSUNG controller's log ,
TSUNG-Erlang Snippet,
<setdynvars sourcetype="file" fileid="NBILM_testUsers" delimiter=";" order="iter">
<var name="minnum"/>
<var name="maxnum"/>
</setdynvars>
<setdynvars sourcetype="eval"
code='fun({Pid,DynVars})->
{ok,Maxfound}=ts_dynvars:lookup(maxnum,DynVars),
Maxstr = lists:flatten(io_lib:format("~p",[Maxfound])),
{MAX, _} = string:to_integer(Maxstr),
{ok,Minfound}=ts_dynvars:lookup(minnum,DynVars),
Minstr = lists:flatten(io_lib:format("~p",[Minfound])),
{MIN, _} = string:to_integer(Minstr),
{ok,Countern} = ts_dynvars:lookup(counter,DynVars,999),
Counternstr = lists:flatten(io_lib:format("~p",[Countern])),
{Counternum, _} = string:to_integer(Counternstr),
Mnum1 = MAX + Counternum rem ( 2 - 1 ),
Mnum1 end.
'>
<var name="mnum" />
</setdynvars>
Erroneous log events from TSUNG Controller,
=INFO REPORT==== 5-May-2017::11:42:40 ===
ts_client:(5:<0.134.0>) Stop in state think, reason= {badarith,
[{erlang,
'+',
[error,0],
[]},
{erl_eval,
do_apply,6,
[{file,
"erl_eval.erl"},
{line,
669}]},
{erl_eval,
expr,5,
[{file,
"erl_eval.erl"},
{line,
438}]},
{erl_eval,
exprs,5,
[{file,
"erl_eval.erl"},
{line,
122}]},
{ts_client,
handle_next_action,
1,
[{file,
"src/tsung/ts_client.erl"},
{line,
459}]},
{gen_fsm,
handle_msg,
7,
[{file,
"gen_fsm.erl"},
{line,
518}]},
{proc_lib,
init_p_do_apply,
3,
[{file,
"proc_lib.erl"},
{line,
239}]}]}
=ERROR REPORT==== 5-May-2017::11:42:40 ===
** State machine <0.134.0> terminating
** Last message in was {timeout,#Ref<0.0.8.22>,end_thinktime}
** When State == think
** Data == {state_rcv,none,
{{0,0,0,0},0},
undefined,0,10000,"xyz",80,ts_tcp,
{proto_opts,negociate,"/http-bind/",false,"/chat",
"binary",10,3,600000,infinity,infinity,32768,32768,
undefined,undefined,[],false,true},
false,1,undefined,true,undefined,
{1493,964755,255814},
18,18,false,undefined,0,[],<<>>,
{http,0,0,-1,
{none,none},
false,false,
{false,false},
[],"tsung",[]},
0,1,524288,524288,
[{tsung_userid,1}],
ts_http,[],undefined,full}
Reason for termination =
{badarith,[{erlang,'+',[error,0],[]},
{erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,669}]},
{erl_eval,expr,5,[{file,"erl_eval.erl"},{line,438}]},
{erl_eval,exprs,5,[{file,"erl_eval.erl"},{line,122}]},
{ts_client,handle_next_action,1,
[{file,"src/tsung/ts_client.erl"},{line,459}]},
{gen_fsm,handle_msg,7,[{file,"gen_fsm.erl"},{line,518}]},
{proc_lib,init_p_do_apply,3,
[{file,"proc_lib.erl"},{line,239}]}]}
It would be really helpful, if someone can point what am doing incorrectly.
The message says that in the line Mnum1 = MAX + Counternum rem ( 2 - 1 ), you are trying to add error with 0 (by the way Counternum rem ( 2 - 1 ) is always equal to 0 so there must be an error here).
Max is the result of {MAX, _} = string:to_integer(Maxstr),, it is equal to error if Maxstr is not a string starting by an integer:
"123" will return {123,[]}
"123 ab" will return {123," ab"}
"a123" will return {error,no_integer}
an_atom will return {error,not_a_list}
To debug further verify the value of Maxfound and Maxstr
you can also shorten your code using the function io:fread/2 which will directly return an integer.

Erlang application exit,, but vm is still running

My Erlang applicaation processed crashed and then exited, but found that the erlang VM is still running.
I could recieve pong when ping this "suspended node"
Types regs() and the results show below, there is not my app process.
(hub#192.168.1.140)4> regs().
** Registered procs on node 'hub#192.168.1.140' **
Name Pid Initial Call Reds Msgs
application_controlle <0.7.0> erlang:apply/2 30258442 1390
auth <0.20.0> auth:init/1 189 0
code_server <0.26.0> erlang:apply/2 1194028 0
erl_epmd <0.19.0> erl_epmd:init/1 138 0
erl_prim_loader <0.3.0> erlang:apply/2 2914236 0
error_logger <0.6.0> gen_event:init_it/6 49983527 0
file_server_2 <0.25.0> file_server:init/1 16185407 0
global_group <0.24.0> global_group:init/1 107 0
global_name_server <0.13.0> global:init/1 1385 0
gr_counter_sup <0.43.0> supervisor:gr_counter_sup 253 0
gr_lager_default_trac <0.70.0> gr_counter:init/1 121 0
gr_lager_default_trac <0.72.0> gr_manager:init/1 46 0
gr_lager_default_trac <0.69.0> gr_param:init/1 117 0
gr_lager_default_trac <0.71.0> gr_manager:init/1 46 0
gr_manager_sup <0.45.0> supervisor:gr_manager_sup 484 0
gr_param_sup <0.44.0> supervisor:gr_param_sup/1 253 0
gr_sup <0.42.0> supervisor:gr_sup/1 237 0
inet_db <0.16.0> inet_db:init/1 749 0
inet_gethost_native <0.176.0> inet_gethost_native:serve 4698517 0
inet_gethost_native_s <0.175.0> supervisor_bridge:inet_ge 41 0
init <0.0.0> otp_ring0:start/2 30799457 0
kernel_safe_sup <0.35.0> supervisor:kernel/1 278 0
kernel_sup <0.11.0> supervisor:kernel/1 47618 0
lager_crash_log <0.52.0> lager_crash_log:init/1 97712230 0
lager_event <0.50.0> gen_event:init_it/6 1813660437 0
lager_handler_watcher <0.51.0> supervisor:lager_handler_ 358 0
lager_sup <0.49.0> supervisor:lager_sup/1 327 0
net_kernel <0.21.0> net_kernel:init/1 110769667 0
net_sup <0.18.0> supervisor:erl_distributi 313 0
os_cmd_port_creator <0.582.0> erlang:apply/2 81 0
rex <0.12.0> rpc:init/1 15653480 0
standard_error <0.28.0> erlang:apply/2 9 0
standard_error_sup <0.27.0> supervisor_bridge:standar 41 0
timer_server <0.100.0> timer:init/1 59356077 0
user <0.31.0> group:server/3 23837008 0
user_drv <0.30.0> user_drv:server/2 12239455 0
** Registered ports on node 'hub#192.168.1.140' **
Name Id Command
ok
It rarely occurs, but anyone explains it?
System: CentOS 5.8
Erlang: R15B03

Resources