Skip to content

Commit d2e8b15

Browse files
committed
Fix BEAM crash from from port/NIF thread
1 parent b6c6537 commit d2e8b15

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

erts/emulator/beam/erl_process.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2942,9 +2942,14 @@ ERTS_GLB_INLINE
29422942
Uint32 erts_sched_local_random(Uint additional_seed)
29432943
{
29442944
ErtsSchedulerData *esdp = erts_get_scheduler_data();
2945-
esdp->rand_state++;
2946-
return erts_sched_local_random_hash_64_to_32_shift(esdp->rand_state
2947-
+ additional_seed);
2945+
if(ERTS_UNLIKELY(esdp == NULL))
2946+
return erts_sched_local_random_hash_64_to_32_shift(((Uint64)(UWord)&additional_seed)
2947+
+ additional_seed);
2948+
else {
2949+
esdp->rand_state++;
2950+
return erts_sched_local_random_hash_64_to_32_shift(esdp->rand_state
2951+
+ additional_seed);
2952+
}
29482953
}
29492954

29502955
#ifdef DEBUG

0 commit comments

Comments
 (0)