Ethernet shild + sim900 module loop does not work

Hello. Faced with strange problem: When using the following code:

#include <SPI.h>
#include <Ethernet.h>

#include "SIM900.h"
#include <SoftwareSerial.h>
//If not used, is better to exclude the HTTP library,
//for RAM saving.
//If your sketch reboots itself proprably you have finished,
//your memory available.
//#include "inetGSM.h"

//If you want to use the Arduino functions to manage SMS, uncomment the lines below.
#include "sms.h"
SMSGSM sms;

#define SEND_LED 9

#define GET_SMS_LED 8

int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];

String sms_text;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//IPAddress ip(191,11,1,1);



//char server[] = "112.travel";
IPAddress server(194,187,48,247); 
int send_sms_status = 2;

EthernetClient client;

void setup() {
  
  Serial.begin(9600);
  
   pinMode(SEND_LED, OUTPUT);
  
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
    
      // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for(;;)
      ;
  }
  
  delay(1000);
  
      Serial.print("My IP address: ");
    
      for (byte thisByte = 0; thisByte < 4; thisByte++) {
        Serial.print(Ethernet.localIP()[thisByte], DEC);
        Serial.print("."); 
      }
      Serial.println();
  
  
   Serial.println("GSM Shield testing.");
  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  if (gsm.begin(2400)){
    Serial.println("\nstatus=READY");
    started=true;  
  }
  else Serial.println("\nstatus=IDLE");
  
  
  
  if(started){
    //Enable this two lines if you want to send an SMS.
    //if (sms.SendSMS("3471234567", "Arduino SMS"))
      //Serial.println("\nSMS sent OK");
  }
  
//    pinMode(SEND_LED, OUTPUT);
//   pinMode(GET_SMS_LED, OUTPUT);
  
 //IPAddress ip(Ethernet.localIP());
 
 
 /*
 Serial.println("sdsd");
 Serial.println(str_replace("sms text is!!!"));
 Serial.println("sdsd1");
 */
 // connectToServer(str_replace("sms text is!!!"), "+380501234567");
  
};

boolean StartGetResult = false;
boolean start_send_serv = false;
String server_result, ServRes;

long PrevMillForSend = 0;

void loop () {
 
 //func_send_server (str_replace("sms text is!!!"), "+380501234567");
   
 if(started){
    //Read if there are messages on SIM card and print them.
    if(gsm.readSMS(smsbuffer, 160, n, 20))
    {
      Serial.println(n);
      Serial.println(smsbuffer);
    }
    delay(1000);
    
  }   
   
  
}

the port there is no output. If I removed from the loop of inspection of incoming sms:

#include <SPI.h>
#include <Ethernet.h>

#include "SIM900.h"
#include <SoftwareSerial.h>
//If not used, is better to exclude the HTTP library,
//for RAM saving.
//If your sketch reboots itself proprably you have finished,
//your memory available.
//#include "inetGSM.h"

//If you want to use the Arduino functions to manage SMS, uncomment the lines below.
#include "sms.h"
SMSGSM sms;

#define SEND_LED 9

#define GET_SMS_LED 8

int numdata;
boolean started=false;
char smsbuffer[160];
char n[20];

String sms_text;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
//IPAddress ip(191,11,1,1);



//char server[] = "112.travel";
IPAddress server(194,187,48,247); 
int send_sms_status = 2;

EthernetClient client;

void setup() {
  
  Serial.begin(9600);
  
   pinMode(SEND_LED, OUTPUT);
  
   while (!Serial) {
    ; // wait for serial port to connect. Needed for Leonardo only
  }
    
      // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for(;;)
      ;
  }
  
  delay(1000);
  
      Serial.print("My IP address: ");
    
      for (byte thisByte = 0; thisByte < 4; thisByte++) {
        Serial.print(Ethernet.localIP()[thisByte], DEC);
        Serial.print("."); 
      }
      Serial.println();
  
  
   Serial.println("GSM Shield testing.");
  //Start configuration of shield with baudrate.
  //For http uses is raccomanded to use 4800 or slower.
  if (gsm.begin(2400)){
    Serial.println("\nstatus=READY");
    started=true;  
  }
  else Serial.println("\nstatus=IDLE");
  
  
  
  if(started){
    //Enable this two lines if you want to send an SMS.
    //if (sms.SendSMS("3471234567", "Arduino SMS"))
      //Serial.println("\nSMS sent OK");
  }
  
//    pinMode(SEND_LED, OUTPUT);
//   pinMode(GET_SMS_LED, OUTPUT);
  
 //IPAddress ip(Ethernet.localIP());
 
 
 /*
 Serial.println("sdsd");
 Serial.println(str_replace("sms text is!!!"));
 Serial.println("sdsd1");
 */
 // connectToServer(str_replace("sms text is!!!"), "+380501234567");
  
};

boolean StartGetResult = false;
boolean start_send_serv = false;
String server_result, ServRes;

long PrevMillForSend = 0;

void loop () {
 
 //func_send_server (str_replace("sms text is!!!"), "+380501234567");
   
 if(started){
    //Read if there are messages on SIM card and print them.
    /*if(gsm.readSMS(smsbuffer, 160, n, 20))
    {
      Serial.println(n);
      Serial.println(smsbuffer);
    }*/
    delay(1000);
    
  }   
   
  
}

all work is fine. Status is GMS = READY and normally displays my IP. Can someone tell me what be the problem? I would greatly appreciate your help!

Which Arduino are you using? Have you considered that you may be running out of memory?

thanks of answer! I use Arduino Uno, Atmega 328

I'm having a really hard time reading code that that stuff that dances waltzes wanders all over the place.

Use Tools + something Auto Format to corral the code into behaving, and get rid of the commented out stuff.