Would you like to react to this message? Create an account in a few clicks or log in to continue.

You are not connected. Please login or register

SimulIDE_0.4.15-SR10.AppImage Segmentation Fault

3 posters

Go down  Message [Page 1 of 1]

mvandorp



Hi,

I finally found the time to continue with a project which was laying around for about 6 months. To refresh my memory, UI loaded the code into SimulIDE, but it crashed.

I updated SimulIDE (my OS was already updated) and all libraries used.
The code is quite large, so I inserted breaks to pinpoint where the crash occurred.

I am on Debian 5.10.140-1 (2022-09-02), named bullseye (version 11)
I am currently using SimulIDE_0.4.15-SR10.AppImage

When I start SimulIDE from the CLI, load the schematics, and run the arduino code, it crashes with the following showing on the CLI (green text is output from my arduino code):

./SimulIDE_0.4.15-SR10.AppImage

"    Loading Component sets at:"
"/tmp/.mount_SimulIJD4uAf/simulide/share/simulide/data"

"        Loaded Component set:           " "arduinos.xml"
"        Loaded Component set:           " "avrs.xml"
"        Loaded Component set:           " "ic74.xml"
"        Loaded Component set:           " "icCD.xml"
"        Loaded Component set:           " "keys.xml"
"        Loaded Component set:           " "led_display.xml"
"        Loaded Component set:           " "pics.xml"
"        Loaded Component set:           " "ternary.xml"
"        Loaded Component set:           " "tools.xml"
"        Loaded Component set:           " "unsorted.xml"
"        Loaded Component set:           " "ussr.xml"



   Simulation Stopped


Frames/Sec: 20 Frames per Sec
Steps/Fram: 50000 Simul. Steps

Speed  PER: 100%
Speed  SPS: 1000000 Steps Per Sec
Simul Step: 1000 nanoSeconds
React Rate: 50 Simul. Steps


Frames/Sec: 20 Frames per Sec
Steps/Fram: 50000 Simul. Steps

Speed  PER: 100%
Speed  SPS: 1000000 Steps Per Sec
Simul Step: 1000 nanoSeconds
React Rate: 50 Simul. Steps


Frames/Sec: 20 Frames per Sec
Steps/Fram: 50000 Simul. Steps

Speed  PER: 100%
Speed  SPS: 1000000 Steps Per Sec
Simul Step: 1000 nanoSeconds
React Rate: 50 Simul. Steps

       Initializing "Arduino Mega-28" ...
   UART 0
   UART 1
   UART 2
   UART 3

AvrProcessor::setDevice Avr Init:  "atmega2560" true
"/tmp/.mount_SimulIJD4uAf/simulide/share/simulide/data/images/mega_board.png"
    ... "Arduino Mega-28" OK

AvrCompBase::attachPins Found SDA SCL

Frames/Sec: 20 Frames per Sec
Steps/Fram: 50000 Simul. Steps

Speed  PER: 100%
Speed  SPS: 1000000 Steps Per Sec
Simul Step: 1000 nanoSeconds
React Rate: 50 Simul. Steps


Starting Circuit Simulation...

 Initializing 233 eElements
 Initializing 0 Buses
 Initializing 41 eNodes

Circuit Matrix looks good

   Simulation Running...

0;255;3;0;14;Gateway startup complete..
0;255;0;0;17;2.3.2.
setup() started.....
The Magic from EEPROM is: -1..
Forcing defaults in EEPROM..
Filling EEPROM with defaults..
Display 1 Address is set to 3C..

AvrCompBase::twenChanged Enable: 1
AvrCompBase::twenChanged i2cFreq: 100000
Segmentation fault


The arduino code triggering this is display1.begin(...), as you can see below:

Code:

...
// Instance is globally created
ifdef WiWo_DISPLAY1_USES_SSD1306
  Adafruit_SSD1306 display1(SCREEN1_WIDTH, SCREEN1_HEIGHT, &Wire, SCREEN1_RESET);
#endif // WiWo_DISPLAY1_USES_SSD1306
...
void setup () {
...
 // S11: Start the display
 #ifdef WiWo_DISPLAY1_ENABLED            // Enable this when the system has a display
   DEBUG(F("Display 1 Address is set to ")); DEBUGLN2(SCREEN1_ADDRESS,HEX);
   // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
   if(!display1.begin(SSD1306_SWITCHCAPVCC, SCREEN1_ADDRESS))
   {
     ERRORLN(F("1:SSD1306 allocation failed"));
   }
...

The DEBUG, DEBUGLN2 and ERRORLN are macro's around Serial.print

It is very well possible -even likely- that my Arduino code is far from perfect, but my understanding is that this should result in a non-functioning simulation. It should NOT lead to a crash of the simulator itself.

I also made a strace from this crash, but I lack the knowledge (and experience) to correctly interpret the output. For completeness is included the last lines from the strace output below:

...
Display Address is set to 3C..
poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])
writev(4, [{iov_base=";\3o\1\r\0\0\1\0\0\0\0D\2(\0\216\1\27\0\234\4\373\2\224\0d\08\5\373\2"..., iov_len=1524}], 1) = 1524
poll([{fd=4, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=4, revents=POLLOUT}])
writev(4, [{iov_base="+\0\1\0", iov_len=4}], 1) = 4
futex(0x7ffcad7b2ad8, FUTEX_WAIT_PRIVATE, 0, NULL) = 0
futex(0x10f7c98, FUTEX_WAKE_PRIVATE, 1) = 0
AvrCompBase::twenChanged Enable: 1
AvrCompBase::twenChanged i2cFreq: 100000
+++ killed by SIGSEGV +++

As far as I understand the above info, something goes wrong when starting the i2c bus. I even disconnected the i2c pins in the circuit just to make sure it wasn't wrongly connected, but the simulator still crashes.

I'm going to perform 2 more tests:

* I will try the above on a windows system with the windows version of SimulIDE
* I will try different versions of SimulIDE


Any help and insight is truly appreciated.

Marcel

2SimulIDE_0.4.15-SR10.AppImage Segmentation Fault Empty Update: Circuit does matter! Thu Sep 15, 2022 2:57 pm

mvandorp



It gets weirder!

I reduced the Arduino code to:

Code:

#include <Arduino.h>

#include <SPI.h>
#include <Wire.h>

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

Adafruit_SSD1306 display1(128,64,&Wire,-1);

void setup() {
  Serial.begin(115200);
  Serial.print("Setup started\n");
  Serial.print("SSD1306_SWITCHCAPVCC = ");
  Serial.print(SSD1306_SWITCHCAPVCC);
  if(!display1.begin(2, 60))
    {
      Serial.print(F("1:SSD1306 allocation failed"));
    }
}

void loop() {

}

This is in the editor of SimulIDE itself. I change the target board to Arduino Mega (in properties of code page), compile and upload.

In the console I see:

"/home/arduino/arduino-builder" -compile -hardware "/home/arduino/hardware" -tools "/home/arduino/tools-builder" -tools "/home/arduino/hardware/tools/avr" -built-in-libraries "/home/arduino/libraries" -libraries "/home/marcel/Arduino/libraries" -fqbn=arduino:avr:megaADK -build-path "/home/marcel/.local/share/simulide/codeeditor/buildIno/build" -build-cache "/home/marcel/.local/share/simulide/codeeditor/buildIno/cache" "/home/marcel/effe/display-test.ino"

Sketch uses 14342 bytes (5%) of program storage space. Maximum is 253952 bytes.

Global variables use 559 bytes (6%) of dynamic memory, leaving 7633 bytes for local variables. Maximum is 8192 bytes.


    SUCCESS!!! Compilation Ok
-------------------------------------------------------

Uploading:
/home/SimulIDE_0.4.15-SR9_Lin64/bin/display-test.hex


FirmWare Uploaded to atmega2560

When my circuit is just an Arduino Mega, I can start the simulation. Nothing happens, of course, but it also does NOT crash!

When I load my real circuit, compile and upload again, then the simulator crashes as soon as I start the circuit.

Then I uploaded my circuit, removed all connections to the Arduino Mega, uploaded the code and tested, and the simulator didn't crash!

Then I reconnected each wire as follows:

* stop simulation
* reconnect a wire
* start simulation

I assumed the simulator would crash at some point, but to my surprise, I was able to reconnect everything back as it was, and the simulation didn't crash.

So I became bold, took my complete code and loaded this in the current circuit and behold: everything works as expected! The simulation does everything, and I can make some changes in the code which are reflected in the simulation! So far, so good!

As a last test, I saved my current, working circuit under a different name (WiWoAlarm3_repaired.simu). I closed the simulator, reopened it,  loaded the repaired circuit, loaded the firmware, and behold: the simulator crashes as soon as the simulation is started!

The exact same circuit/software does work if I first remove connections to the arduino and then reconnect them. But if I save the working circuit/code combination, the simulator crashes when I try to start it directly after loading the circuit from disk.

I am lost; if needed, I am willing to upload my circuit file for debugging purposes.

mvandorp



I narrowed it down even further.

I worked the other way around: I disconnected a wire and started the simulation, which crashed the simulator.

Finally the sim stopped crashing when I disconnected a Beeper from pin 13. When I reconnected the Beeper, the sim kept working.

Next test was loading the circuit, only disconnect the beeper and test. Indeed the sim kept working.

Then as a workaround, I added an open switch between beeper and pin 13, but the sim crashed again.

Then it occurred to me: The sim crashes when something is connected to the + side of the Beeper! A final test: I connected a resistor to the beeper, but left the other side of the resistor unconnected. And yes, the sim crashed again!

My conclusion, is that the beeper is the culprit. But only after loading the file; If you disconnect and reconnect it, then the sim works fine.

As the beeper is just 'ear candy', I am happy to leave it out for now; I can fix the rest of the code and at the end I will test with the beeper.

Just a thought: could this be caused by an error in the audio driver of my OS? Currently my audio is non-functional on my system...

arcachofo

arcachofo

I am lost; if needed, I am willing to upload my circuit file for debugging purposes.
Yes, to know what is happening I need to reproduce the issue.

Just a thought: could this be caused by an error in the audio driver of my OS? Currently my audio is non-functional on my system...
I think simulide should not crash, but you can try to test a simple circuit with just a beeper and see if there is some problem.

spark



I haven't tried anything as complicated as in this topic (and don't know enough about it to do so) but I'm using SimulIDE_0.4.15-SR10.AppImage on Linux Mint 20.3 . SimulIDE sometimes crashes (usually after changing something while the simulation is still running) but in my case the crashes don't happen as often as to form a big problem.

Sponsored content



Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum