Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8134423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:01:10+00:00 2026-06-06T10:01:10+00:00

A really weird thing happens in this code JNIEXPORT jintArray JNICALL Java_jsdr_SdrLibrary_getTunerGains (JNIEnv *

  • 0

A really weird thing happens in this code

    JNIEXPORT jintArray JNICALL Java_jsdr_SdrLibrary_getTunerGains
     (JNIEnv * env, jclass obj, jlong pointer) {
      rtlsdr_dev_t * dev;
      int * gains;
      jintArray ji;
      jint * buff;
      int i;
      int size;

      dev = (rtlsdr_dev_t *) pointer;
      size = rtlsdr_get_tuner_gains(dev, gains);

      if (size <= 0)
        .. throws an error, irrelevant code ..

      buff = (jint *) malloc(size * sizeof(jint));
      for (i = 0; i < size; i++) buff[i] = gains[i];

      ji = (*env)->NewIntArray(env, size);
      (*env)->SetIntArrayRegion(env, ji, 0, size, buff);
      return ji;
  }

The method actually returns a result that I can handle in Java with

  System.out.println(printArray(SdrLibrary.getTunerGains(pointer)));

where printArray is just a simple

public static String printArray(int[] arr) {
    String buff = "["+arr[0];
    for (int i = 1; i < arr.length; i++) buff+=", "+arr[i];
    return buff+"]";
}

The output is the following

[-10, 15, 40, 65, 90, 115, 140, 165, 190, 215, 240, 290, 340, 420, 430, 450, 470, 490]
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x6d86c2ff, pid=7160, tid=5880
#
# JRE version: 6.0_31-b05
# Java VM: Java HotSpot(TM) Client VM (20.6-b01 mixed mode, sharing windows-x86 )
# Problematic frame:
# V  [jvm.dll+0x7c2ff]
#
# An error report file with more information is saved as:
# C:\Users\Marto\workspace\JSDR\hs_err_pid7160.log
#
# If you would like to submit a bug report, please visit:
#   http://java.sun.com/webapps/bugreport/crash.jsp
#

As you can see it returns a result but immediately after that the JM crashes and no further lines get executed. I would definitely appreciate any help! Thank you!

EDIT: If I remove the call to rtlsdr_get_tuner_gains and instead initialize the gains array manually, no error is observed. Since this method is inside a dll, can I prevent it somehow from crashing the JNI?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T10:01:11+00:00Added an answer on June 6, 2026 at 10:01 am

    I discovered the source of the error. It turns out that the original library does not allocate the buffer that is being passed to it resulting in overwriting memory which is not held by the JNI (thanks to QuantumMechanic to giving me the simple idea to actually look at the source of the library).

    The solution was simple enough. Change this

      int * gains;
    

    to this

      int gains[30];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is really weird, and I cannot see why this is happening. In the
This struck me as really weird behaviour and I spent a while checking for
Well this is a really weird issue, I really didn't find anything on this
I have a really weird problem with fgets() in C. Below is the code
I have a really weird thing happening in my wpf application. Every time I
I have this really weird bug. When I scroll down my table view, down
This is a really weird one and I'm wondering if I need to change
This is the most weird thing that has ever happened to me when programming
Ok, this is one of those really weird errors that seems like the machine's
(The coordinate conventions in my code might be pretty messy for some---it's really weird.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.