hello everyone,
NIM newbie here, i'm getting "SIGSEGV: illegal storage access" (attempt to read from nil?) crash randomly. i have been trying to find what's causing it but i can't.
below are the code snippets i'm using and the crash trace backs' screenshots. what's wrong? thank you in advance
https://imgur.com/a/bdVCJbh https://imgur.com/a/SUtjEpa
# GET
proc http_get_data(params: string): string =
  var obj_response: Response
  
  # CHECK SERVER
  check_server()
  
  var client = newHttpClient(timeout = HTTP_TIMEOUT)
  var full_url = main_server & api_path & "?" & params
  
  try:
    obj_response = client.get(full_url)
  except OSError:
    when DEBUG:
      log_local("[!] http_get_data() FAILED / OSError EXCEPTION RAISED.", log_http)
    return ""
  except:
    when DEBUG:
      log_local("[!] http_get_data() FAILED / EXCEPTION RAISED.", log_http)
    return ""
  finally:
    client.close()
  
  if obj_response == nil:
    when DEBUG:
      log_local("[!] http_get_data() NIL RESPONSE/OBJECT EXITING.", log_http)
    return ""
  
  var data = obj_response.body
  
  when DEBUG:
    log_local("http_get_data() GET: "¶ms, log_http)
    log_local("http_get_data() URL: "&full_url, log_http)
    log_local("http_get_data() REPONSE: "&data, log_http)
  
  return data
# CHECK SERVER
proc check_server() =
  var full_url = main_server & api_path & "?id=6"
  var obj_response: Response
  
  while true:
    var client = newHttpClient(timeout = HTTP_TIMEOUT) # 25 seconds
    try:
      obj_response = client.get(full_url)
      if obj_response != nil and obj_response.body == SERVERUP:
        when DEBUG:
          log_local("check_server() HTTP CODE: "&obj_response.status, log_server)
          log_local("check_server() HTTP BODY: "&obj_response.body, log_server)
          log_local("check_server() SERVER IS UP!", log_server)
        return
    except OSError:
      when DEBUG:
        log_local("[!] SERVER NOT FOUND OR DOWN. RETRYING. OSError RAISED.", log_server)
    except:
      when DEBUG:
        log_local("[!] SERVER NOT FOUND OR DOWN. RETRYING. SOME EXCEPTION RAISED.", log_server)
    finally:
      client.close()
    
    sleep(3000)