Skip to content

[showtech] Fix printGpio segfault#729

Open
huyc-arista wants to merge 1 commit into
facebook:mainfrom
huyc-arista:fix-oss-showtech-errors
Open

[showtech] Fix printGpio segfault#729
huyc-arista wants to merge 1 commit into
facebook:mainfrom
huyc-arista:fix-oss-showtech-errors

Conversation

@huyc-arista

@huyc-arista huyc-arista commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

Pre-submission checklist

  • I've ran the linters locally and fixed lint errors related to the files I modified in this PR. You can install the linters by running pip install -r requirements-dev.txt && pre-commit install
  • pre-commit run

Summary

Fix potential printGpio() segfault.

  • Adds error handling to printGpio to prevent segfaults when gpiod_chip_open() fails.
  • Update gpio printing format

Test Plan

Ran showtech --details gpio with invalid gpio path and ensure no crash

[root@vpr424 admin]# showtech --details gpio --config_file "/opt/fboss/share/platform_configs/showtech.json"
I1121 18:42:00.221478  6438 ConfigLib.cpp:50] Using config file: /opt/fboss/share/platform_configs/showtech.json
I1121 18:42:00.221558  6438 Main.cpp:72] Executing: gpio
##### GPIO Information #####
#### GPIO Chip Details /run/devmap/gpiochips/INVALID_GPIO ####
line  0: SCD_DONE        -> Error: failed to read gpio line: GpiodLineTrace: Invalid gpiod_chip* passed in for SCD_DONE
line  1: OVER_TEMP_L     -> Error: failed to read gpio line: GpiodLineTrace: Invalid gpiod_chip* passed in for OVER_TEMP_L
line  2: SYS_PGOOD       -> Error: failed to read gpio line: GpiodLineTrace: Invalid gpiod_chip* passed in for SYS_PGOOD
line  3: P1V2_CP_PGOOD   -> Error: failed to read gpio line: GpiodLineTrace: Invalid gpiod_chip* passed in for P1V2_CP_PGOOD
line  4: SCD_CRC_ERR     -> Error: failed to read gpio line: GpiodLineTrace: Invalid gpiod_chip* passed in for SCD_CRC_ERR
line  5: P1V0_CP_PGOOD   -> Error: failed to read gpio line: GpiodLineTrace: Invalid gpiod_chip* passed in for P1V0_CP_PGOOD
line  6: P1V8_CP_PGOOD   -> Error: failed to read gpio line: GpiodLineTrace: Invalid gpiod_chip* passed in for P1V8_CP_PGOOD
line  7: P3V3_CP_PGOOD   -> Error: failed to read gpio line: GpiodLineTrace: Invalid gpiod_chip* passed in for P3V3_CP_PGOOD
line  8: SCD_PRGM_L      -> Error: failed to read gpio line: GpiodLineTrace: Invalid gpiod_chip* passed in for SCD_PRGM_L
line  9: SCD_HOLD_L      -> Error: failed to read gpio line: GpiodLineTrace: Invalid gpiod_chip* passed in for SCD_HOLD_L
line 12: CPU_QSPI_SEL    -> Error: failed to read gpio line: GpiodLineTrace: Invalid gpiod_chip* passed in for CPU_QSPI_SEL
line 14: SCD_RESET_L     -> Error: failed to read gpio line: GpiodLineTrace: Invalid gpiod_chip* passed in for SCD_RESET_L

@meta-cla meta-cla Bot added the CLA Signed label Dec 8, 2025
@huyc-arista

Copy link
Copy Markdown
Contributor Author

@somasun Can we assume showtech can always be run as root user? Non root showtech output is still usefull just not as complete. I don't want this guard to prevent us getting showtech logs if such scenario exist.

@meta-codesync

meta-codesync Bot commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

@somasun has imported this pull request. If you are a Meta employee, you can view this in D88675606.

@somasun

somasun commented Dec 8, 2025

Copy link
Copy Markdown
Contributor

@somasun Can we assume showtech can always be run as root user? Non root showtech output is still usefull just not as complete. I don't want this guard to prevent us getting showtech logs if such scenario exist.

I think this should be fine.

@huyc-arista huyc-arista force-pushed the fix-oss-showtech-errors branch from ae90d70 to 476b42a Compare January 29, 2026 18:16
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@huyc-arista has updated the pull request. You must reimport the pull request before landing.

@huyc-arista huyc-arista changed the title [showtech] Enforce run as root and fix printGpio segfault Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants