Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(android): overflow due to incorrect data type for time #1014

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions android/measure-android-gradle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ abstract class BuildUploadTask : DefaultTask() {
mappingFile?.let {
addFormDataPart(MAPPING_FILE, it.name, it.asRequestBody())
addFormDataPart(MAPPING_TYPE, TYPE_PROGUARD)
}
} ?: logger.warn("[WARNING]: mapping file not found, symbolication will not work")
addFormDataPart(BUILD_SIZE, appSize)
addFormDataPart(BUILD_TYPE, buildType)
}.build()
Expand Down
10 changes: 5 additions & 5 deletions android/measure/src/main/jni/anr_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static bool init_signal_catcher_tid() {
return true;
}

static void notifyAnrDetected(long timeMs) {
static void notifyAnrDetected(long long timeMs) {
if (!is_anr_handler_enabled) {
MSR_LOGD("ANR handler not enabled, discarding detected ANR");
return;
Expand Down Expand Up @@ -155,20 +155,20 @@ static void notifyAnrDetected(long timeMs) {
break;
}

MSR_LOGD("ANR detected at %ld, notifying via JNI", timeMs);
MSR_LOGD("ANR detected at %lld, notifying via JNI", timeMs);
(*env)->CallVoidMethod(env, gBridgeObj, notifyAnrDetectedMethod, timeMs);
if (check_and_clear_exc(env)) {
MSR_LOGE("Failed to call notifyAnrDetected");
}
}

static long get_current_time_ms() {
static long long get_current_time_ms() {
struct timespec ts;
if (clock_gettime(CLOCK_REALTIME, &ts) == -1) {
MSR_LOGE("Failed to get current time");
return -1;
}
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
return (long long)ts.tv_sec * 1000LL;
}

static void block_sigquit() {
Expand All @@ -195,7 +195,7 @@ static void *watchdog_start_routine(__unused void *_) {
MSR_LOGE("Failed to wait on semaphore, ANR detection won't work");
break;
}
long time = get_current_time_ms();
long long time = get_current_time_ms();
notifyAnrDetected(time);
syscall(SYS_tgkill, process_id, signal_catcher_tid, SIGQUIT);
unblock_sigquit();
Expand Down
Loading