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

SEGV crash with externally encoded large maps from port/NIF thread #8208

Open
dotsimon opened this issue Feb 29, 2024 · 1 comment · May be fixed by #8209
Open

SEGV crash with externally encoded large maps from port/NIF thread #8208

dotsimon opened this issue Feb 29, 2024 · 1 comment · May be fixed by #8209
Assignees
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM

Comments

@dotsimon
Copy link
Contributor

Describe the bug
BEAM crashes when a thread sends a large (>128 keys) map externally encoded using e.g. erl_drv_send_term

The problem is that commit 184634a works around having no process by assuming there is a scheduler. For threads created with erl_drv_thread_create or similar this is not true.

To Reproduce
A trivial port program that simply echoes a received term back to the calling process is attached.

Compile the driver with the appropriate flags for your system, t.ex.

gcc -c -fPIC -I/usr/local/otp_25.3/lib/erlang/usr/include -Wall -fno-common -o sigsegv_drv.o sigsegv_drv.c
cc -bundle -flat_namespace -undefined suppress -o sigsegv_drv.so sigsegv_drv.o

Compile the test module
erlc sigsegv_drv.erl

Verify the basic functionality of the test program
sigsegv_drv:go(128).

Reproduce the fault
sigsegv_drv:die().

Expected behavior
BEAM does not crash.
Test program prints "I DID NOT DIE!"

Affected versions
OTP-23.3.4.15+
OTP-24.3.4.2+
OTP-25.1+
OTP-26+

@dotsimon dotsimon added the bug Issue is reported as a bug label Feb 29, 2024
@dotsimon dotsimon linked a pull request Feb 29, 2024 that will close this issue
@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Mar 4, 2024
@dotsimon
Copy link
Contributor Author

dotsimon commented Mar 5, 2024

The test module & port driver didn't get attached so here they are:
sigsegv_drv.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants