Erlang program works on erlang20 but not on erlang24

Hello erlang community,

We have an Erlang project that is functioning perfectly with Erlang 20, but we’re encountering issues when trying to run it with Erlang 24. We’ve reviewed the changes between these versions, but we’re struggling to pinpoint the exact cause of the problem.

Our project is available in this public GitHub repository: GitHub - omayerg/-Erlang-Traffic-Management

We suspect issue is within the communication initialization, this is how we do:

start_link() -> gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
start() -> gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).
start(NODE1,NODE2,NODE3,NODE4,Master) -> gen_server:start_link({local, ?SERVER}, ?MODULE, [NODE1,NODE2,NODE3,NODE4,Master], []).

Here’s what we’ve tried so far:

Compilation: We have successfully compiled the code in both Erlang 20 and Erlang 24 without any errors.

Logs: Unfortunately, the logs aren’t providing much insight into the issue. The application starts up in Erlang 24, but certain functionalities don’t work as expected, unlike in Erlang 20.

Differences: We’ve compared the release notes and documentation for Erlang 24, but we haven’t identified any specific changes that directly affect our project.

Error:
Backup completed successfully!
The node "NODE3010.0.2.15’ is up.
The node ‘NODE3010.0.2.15’ is currently down.
Connected PCS: [ ‘NODE1@10.0.2.15’, ‘NODE2@10.0.2.15’, ‘NODE3@10.0.2.15’,
‘NODE4010.0.2.15’1
sic Backing up PCs connected to ‘NODE3@10.0.2.15°
-Backup completed successfully!
The node ‘NODE3010.0.2.15’ is up.
There is a problem: {badpc,
{‘EXIT’
There is a problem: {badpc,
{поргос, {gen_server, call, [server ,getCarsState 1333)
There is a problem: {badrpc
{noproc, (gen_server, call, [server ‚getCarsstate]3]]]
(‘EXIT’ {noproc, {gen_server, call, [server ,getcarsstate]331)
Ad
There is a problem: {badpc
(’ EXIT’,
(noproc, (gen_server, call, [server ‚getCarsState]3333
(master@10.0.2.15)10>

Image for full error:

You say that it works in Erlang 20 but not Erlang 24.
Have you tried Erlang 22?
It might be informative to kmow which version of Erlang broke it.
Nice project.

1 Like

Hi there!

This started as a university project, right? And now you like to try it with a more recent erlang version?

Here are some points which I noticed when trying to get it running:

  • car_monitor:update_car_locations() this function has a receive with several matches and an after 0 clause, which creates a hot loop.
  • you use the process dictionary, whose usage is discouraged, this could be moved to a process state record
  • ets seems like an overkill to me, but maybe it was required to use it
  • same for the use of nodes, but maybe the distribution was also required.
  • server:start/4 calls gen_server:start_link, which is misleading for a user. (Start means fire and forget, while start_link means if the started server goes down, so does the caller).
  • your host name was hard-coded, makes it a bit less portable.

In my projects I have always used applications with supervision trees, where you get the crash monitoring for free, so to say. If you have an important process, like your server module, you should start it as a child of a supervisor, or at least monitored. If it is just spawned, it can go away without notice.

Edit: I forgot an important detail. Your project runs on Erlang 25. Well, there are some crashes, but the
GUI is created and there are cars driving around and making turns. :slight_smile:

2 Likes