Skip to content

Invalid Entry Pointer When Compiling and Running Linux Port (64bit version) #466

@stevo01

Description

@stevo01

Description

When creating a ThreadX task and passing a pointer to the task's entry function, the pointer is cast to a 32-bit value (ULONG). However, on a 64-bit Linux system, the entry function expects a 64-bit value, resulting in an invalid pointer being passed and causing runtime errors.

  • Target Linux, 64 Bit
  • ThreadX v6.4.2, NetxDuo v6.
  • environment: debian running insight wsl / 64 bit

This issue was observed in the NetX Duo sample code.

Sample

Thread creation:

tx_thread_create(&(ip_ptr->nx_ip_thread), name, _nx_ip_thread_entry, (ULONG)(ALIGN_TYPE)(ip_ptr),
                 memory_ptr, memory_size, priority, priority, 1, TX_AUTO_START);

Thread entry function:

VOID _nx_ip_thread_entry(ULONG ip_ptr_value)
{
...
}

Here, ip_ptr is cast to ULONG, which is 32-bit on some platforms, while the entry function expects a 64-bit value.

I solved the issue by compiling the application into a 32 bit version (compiler argument -m32) but I prefer the usage of 64 bit.
Can anybody give me a hint how to fix that?

Steps to reproduce the behavior:

  • Build the project using GCC 13.2.1 targeting Linux x86_64.
  • Run the application.
  • Observe runtime errors due to invalid pointer in thread entry.

Expected Behavior

The pointer passed to the thread entry function should be correctly interpreted as a 64-bit value, ensuring stable and correct execution.

Impact

This issue is a showstopper for running the Linux port reliably. It prevents correct thread initialization and leads to crashes or undefined behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinghardwareNew hardware or architecture support request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions