box64 icon indicating copy to clipboard operation
box64 copied to clipboard

Discord (Electron app) fails to launch with "free(): invalid pointer" after immediate crash

Open bacone-poteto opened this issue 1 month ago • 15 comments

Issue Description

When attempting to run the Discord application (an Electron/Chromium-based x64 application) using Box64, it consistently results in an immediate crash with a free(): invalid pointer error, even after upgrading Box64 and attempting various compatibility flags.

The crash happens early in the application's initialization sequence, suggesting a deep memory allocation/free issue with the Electron runtime.

Environment

  • Host Architecture: ARM64 (AArch64)
  • Host CPU: MediaTek Kompanio 520 (Cortex-A55)
  • Host OS: Debian/Linux (via ChromeOS Crostini/penguin)
  • Box64 Version (Latest Attempt): Box64 v0.3.9 8aa23c56 built on Nov 23 2025 20:42:16
  • Target Application: Discord (installed via system package, path: /usr/bin/discord)

Steps to Reproduce

  1. Execute the Discord application with standard flags:

    box64 /usr/bin/discord --no-sandbox --disable-gpu
    
  2. The application immediately crashes.

Crash Log (Latest Run with Updated Box64)

The crash consistently produces the same error and backtrace structure:

[BOX64] Box64 v0.3.9 8aa23c56 built on Nov 23 2025 20:42:16
... (omitted successful lib loading)
[BOX64] Warning: Weak Symbol OPENSSL_memory_alloc not found...
[BOX64] Warning: Weak Symbol OPENSSL_memory_free not found...
[BOX64] Warning: Weak Symbol OPENSSL_memory_get_size not found...
free(): invalid pointer
[BOX64] NativeBT: /lib/aarch64-linux-gnu/libc.so.6(__libc_free+0xd8) [0x7fb9162a9c]
[BOX64] EmulatedBT: box64(free+0) [0x30000120]
[BOX64] EmulatedBT: /usr/share/discord/Discord+66a9d3f [0x1066a9d3f]
[BOX64] EmulatedBT: /usr/share/discord/Discord+6718c9a [0x106718c9a]
[BOX64] EmulatedBT: /usr/share/discord/Discord+6718be4 [0x106718be4]
[BOX64] EmulatedBT: /usr/share/discord/Discord+2943a21 [0x102943a21]
[BOX64] EmulatedBT: /usr/share/discord/Discord(__libc_csu_init+45) [0x102897d35]
[BOX64] EmulatedBT: box64(ExitEmulation+0) [0x30000080]
[BOX64] EmulatedBT: /usr/share/discord/Discord(_start+2a) [0x1024d002a]
[BOX64] 7257|SIGABRT @0x7fb9153c18 (...) (x64pc=0x30000133/"???", rsp=0x7fb8dbce98), for accessing 0x3e800001c59 (code=-6)
RAX:0x000000700000c020 RCX:0x00000001011c60aa RDX:0x0000000000000010 RBX:0x000000700000c000 
... (omitted remaining registers)
中止 (コアダンプ)

Attempted Workarounds (All Failed)

The crash persisted even after updating Box64 to the latest commit as of Nov 23, 2025. This suggests an inherent incompatibility in the Electron/Discord launch process on this particular ARM architecture/Box64 combination.

The following Box64 environment variables were tested individually and in various combinations, but none resolved the free(): invalid pointer crash:

  • Memory/Emulation Flags:
    • BOX64_MALLOC=0 (Disable Box64 malloc override)
    • BOX64_MALLOC=1 (Enable Box64 malloc override, default)
    • BOX64_NOSIGSEGV=1 (Disable SIGSEGV catching mechanism)
  • Library/Optimization Flags:
    • BOX64_PREFER_NATIVE=1 (Prefer native libraries over emulated ones)

** Note from the reporter:** I am a native Japanese speaker, and this issue report was written with the assistance of an AI (Gemini) for clarity and accuracy in English.

bacone-poteto avatar Nov 23 '25 12:11 bacone-poteto

Try BOX64_MALLOC_HACK=2.

ksco avatar Nov 23 '25 12:11 ksco

Also, instead of --disable-gpu, you should try --enable-features=Vulkan, it gives you hardware accel if it works.

BOX64_MALLOC_HACK=2 box64 ./discord --enable-features=Vulkan

ksco avatar Nov 23 '25 12:11 ksco

Hello. Following up on the previous request, I conducted additional tests to isolate the cause of the problem.

1. Original SIGABRT Crash Successfully Avoided

The original free(): invalid pointer SIGABRT crash is now consistently avoided by using a specific environment variable setting.

  • The use of BOX64_MALLOC_HACK=2 is essential. When this flag was not present (only the Vulkan flag was used), the same SIGABRT crash reoccurred immediately.

Conclusion: BOX64_MALLOC_HACK=2 appears to successfully resolve the memory corruption issue encountered during the x86-64 Discord binary's initial launch sequence.

2. New Secondary Problem: White Screen Freeze

When launching with BOX64_MALLOC_HACK=2, the application successfully displays a window without crashing, but it immediately results in a white screen freeze (hang), making it unusable.

  • This white screen freeze occurs regardless of the Vulkan flag (--enable-features=Vulkan).

New Symptom Indicators from Logs

During the white screen freeze (which involved a hang of approximately 30 seconds), the following Box64 warning and Electron errors were repeatedly observed in the output:

a) Box64 Warning (Possible Cause of the Hang) The following warning was logged repeatedly before and during the hang:

[BOX64] Warning, of_unconvert(...) left over 0x20000, converted 0x8002

b) Electron Error (Result of the Hang) The application's internal logs show a communication failure related to the renderer process:

Error sending from webFrameMain: Error: Render frame was disposed before WebFrameMain could be accessed

Current Most Stable Command: BOX64_MALLOC_HACK=2 box64 /usr/bin/discord

I hope this new set of logs and analysis helps to narrow down the issue to the next stage (likely threading/IPC or a Box64 specific of_unconvert bug). Thank you for your continued support.


Note: I am a native Japanese speaker, and this comment's analysis and composition were done with the assistance of an AI assistant (Gemini).

bacone-poteto avatar Nov 23 '25 13:11 bacone-poteto

Hello ptitSeb.

As I haven't received a reply yet, I proactively generated the full log file you might need for the investigation of the of_unconvert warning.

I ran the application using the following command:

BOX64_LOG=1 BOX64_MALLOC_HACK=2 box64 /usr/bin/discord

The output was too long to paste directly into the comment, so I have attached the complete log file (log.log) to this issue.log.log The log covers the execution up until the point where the white screen freeze occurs. I hope this provides the necessary detail for the of_unconvert warning and helps you pinpoint the cause of the Electron IPC failure.

Thank you for your patience and hard work!


Note: I am a native Japanese speaker, and this comment's analysis and composition were done with the assistance of an AI assistant (Gemini).

bacone-poteto avatar Nov 24 '25 07:11 bacone-poteto

The of_convert message is probably harmless. Try to add BOX64_DYNAREC_STRONGMEM=1 to avoid the freeze.

Also, it's a good practice to close a ticket when the issue is fixed, and open a new ticket when you have a new issue, even if it's on the same software.

ptitSeb avatar Nov 24 '25 07:11 ptitSeb

Hello ptitSeb.

Thank you for the quick patch (2fd32381). I have compiled and tested the latest commit.

Unfortunately, the white screen freeze (hang) persists when launching Discord using the command: BOX64_MALLOC_HACK=2 box64 /usr/bin/discord

New Symptoms / Logs:

  1. Freeze: It still hangs for about 30 seconds after displaying the Discord Updater window.
  2. Warning: The of_unconvert warning continues to appear repeatedly during the hang, with a slightly modified value:

[BOX64] Warning, of_unconvert(...) left over 0x20000, converted 0x8402

  1. New Log Attached: I have attached the complete log output from this latest run as log2.log for your further analysis. (This log was generated without the full debug BOX64_LOG=1 flag).log2.log

Also, I have confirmed that networking and DNS resolution are working correctly within Crostini (dig discord.com is successful). The issue seems to be purely emulation-related, likely related to the remaining of_unconvert memory conversion error.

Thank you for your continued support!


Note: I am a native Japanese speaker, and this comment's analysis and composition were done with the assistance of an AI assistant (Gemini).

bacone-poteto avatar Nov 24 '25 14:11 bacone-poteto

Try this command:

BOX64_DYNAREC_STRONGMEM=1 BOX64_MALLOC_HACK=2 box64 /usr/bin/discord

ptitSeb avatar Nov 24 '25 14:11 ptitSeb

Hello ptitSeb.

Thank you for the new command. I have just tested it with the following configuration: BOX64_DYNAREC_STRONGMEM=1 BOX64_MALLOC_HACK=2 box64 /usr/bin/discord

Unfortunately, the result is the same: the white screen freeze (hang) persists when the Discord Updater window appears.

The of_unconvert warning is still printed repeatedly, with the same values as before:

[BOX64] Warning, of_unconvert(...) left over 0x20000, converted 0x8402

I have attached the complete log output from this run as log3.log for your reference.

It seems the issue is indeed rooted in the memory protection flags conversion rather than memory synchronization. I hope log3.log helps you pinpoint the error around the 0x8402 conversion.

Thank you for your patience and effort!


Note: I am a native Japanese speaker, and this comment's analysis and composition were done with the assistance of an AI assistant (Gemini).

bacone-poteto avatar Nov 24 '25 14:11 bacone-poteto

of_unconvertメッセージは無害です

Try to build box64 with BAD_PKILL (this is a build option, pass it to the cmake command as -DBAD_PKILL=ON or use ccmake to toggle it).

ptitSeb avatar Nov 24 '25 14:11 ptitSeb

Hello ptitSeb.

I have compiled Box64 with the -DBAD_PKILL=ON flag (latest commit 8a40b115) and tested Discord.

The hang is infinite and persists. I still have to terminate the process manually (Ctrl+C).

The behavior is exactly the same: the application stops immediately after the repeated of_unconvert warnings: [BOX64] Warning, of_unconvert(...) left over 0x20000, converted 0x8402

New observation: During this last run, the terminal output was flooded with massive amounts of / characters (e.g., ////////////////////////////////////////////////////////////), which pushed the initial log off my terminal screen. I suspect this is some kind of unexpected debug output or infinite loop in a print function, which may be related to the hang.

I have re-attached a log file, but please note that due to the terminal flooding, the beginning of the log might be incomplete or missing the new output with the slashes. log3.log Thank you for your tireless work on this!


Note: I am a native Japanese speaker, and this comment's analysis and composition were done with the assistance of an AI assistant (Gemini).

bacone-poteto avatar Nov 24 '25 15:11 bacone-poteto

I've pushed a profile for Discord. Please rebuild and try again. Just do ./discord --enable-features=Vulkan or ./discord --disable-gpu this time, it should work.

ksco avatar Nov 24 '25 16:11 ksco

Also you can disable the -DBAD_PKILL option now, it's not related.

ksco avatar Nov 24 '25 16:11 ksco

Hello ksco,

Thank you for the Discord profile and the new instructions. I have rebuilt Box64 without the -DBAD_PKILL option (latest commit 12580e59).

Unfortunately, both tests resulted in an infinite white screen freeze again.

Command Tested Result Observation Log
./discord --enable-features=Vulkan Infinite Freeze White screen. discord_enable_vulkan_log.txt
./discord --disable-gpu Infinite Freeze White screen (Previously, this option caused a change to a gray screen before freezing, but now it returns to white). discord_gpu_off_log.txt

The behavior is consistent: the hang occurs immediately after the repeated of_unconvert warnings, just like before. It seems the issue is not related to the application's startup options but something deeper in Box64's handling of memory or threading.

I have attached the logs for both attempts.

Thank you for your continuous support!


Note: I am a native Japanese speaker, and this comment's analysis and composition were done with the assistance of an AI assistant (Gemini).

bacone-poteto avatar Nov 25 '25 11:11 bacone-poteto

You are using Crostini right? you may need to build with BAD_SIGNAL at least if it's not already the case.

ptitSeb avatar Nov 25 '25 11:11 ptitSeb

Also, try the deb file from https://discord.com/download, that's what I used for testing, and it worked for me.

ksco avatar Nov 25 '25 15:11 ksco