開發平台(Platform): (Ex: Win10, Linux, ...)
Linux
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
gcc x64 4.8.3 或4.8.5
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
使用void** 與void*結果不一致
不曉得是compiler bug或是shared memory的address是否有地雷
餵入的資料(Input):
可以使用
python -c 'print("\x55\xAA\x55\xAA")' > struct.bin
產生測資 檔名一定要struct.bin
預期的正確結果(Expected Output):
執行以下兩行程式片段應該一樣結果
以下是call兩個不同函數
load_table_from_shm_voidpp((void**)&g_test_struct);
load_table_from_shm_voidp((void*)g_test_struct);
錯誤結果(Wrong Output):
load_table_from_shm_voidp((void*)g_test_struct);
執行到read會取得errno=14 bad address
用gdb看bt, 傳入的void*會是(void*)0
程式碼(Code):(請善用置底文網頁, 記得排版)
gist
https://gist.github.com/swt02026/d6bafca53b375e62d807c33f33a0b694
補充說明(Supplement):
因為是公司的程式碼
所以我修改成最小能重現相同狀況的程式碼
編譯參數要加上 -std=gnu11