Bug 20 - Undefined behavior caused by NUMA function in eal_memory
Summary: Undefined behavior caused by NUMA function in eal_memory
Status: RESOLVED FIXED
Alias: None
Product: DPDK
Classification: Unclassified
Component: core (show other bugs)
Version: unspecified
Hardware: All Linux
: Normal normal
Target Milestone: ---
Assignee: Anatoly Burakov
URL:
Depends on:
Blocks:
 
Reported: 2018-04-01 14:30 CEST by Solal Pirelli
Modified: 2018-10-25 14:57 CEST (History)
2 users (show)



Attachments

Description Solal Pirelli 2018-04-01 14:30:07 CEST
In linuxapp's eal_memory.c, the map_all_hugepages function begins by declaring and initializing variables, including a nodemask (http://dpdk.org/browse/dpdk/tree/lib/librte_eal/linuxapp/eal/eal_memory.c?h=v18.02#n344).

However, this initialization occurs before the numa_available function is called. According to the libnuma documentation (https://linux.die.net/man/3/numa), all other functions have undefined behavior if numa_available returns -1.

The initialization of the nodemask needs to be moved after the numa_available call, and consequently its freeing at the end of the function needs to be conditional on it not being NULL.
Comment 1 Anatoly Burakov 2018-08-29 14:22:00 CEST
Patch submitted:

http://patches.dpdk.org/patch/43974/
Comment 2 Ajit Khaparde 2018-08-29 19:53:59 CEST
Anatoly,
Assigning the bug to you so that you can close it once the patch is applied.

Thanks
Ajit
Comment 3 Anatoly Burakov 2018-10-25 14:57:20 CEST
Version 3 applied: http://patches.dpdk.org/patch/45065/

Note You need to log in before you can comment on or make changes to this bug.